Where is the Tuple(String,String)#.to_h defined?

e.g.

ic(1.14.0):001> {"hello", "world"}.to_h
 => {'h' => 'e', 'w' => 'o'}

Why it output this result?

Thanks

It’s implemented in Enumerable#to_h.
This method creates a mapping item[0] => item[1] which in the case of String items are the first and second characters.

1 Like