After I've learned Hash#index I'd expect I'm able to guess correctly what
Hash#indexes does. But I'm not.
h = {"abc" => 123, "def" => 456}
list = h.keys + h.values
a = list.collect { |obj| h.index(obj) }
b = h.indexes(*list)
p list, a, b
p a==b
outputting:
["def", "abc", 456, 123]
[nil, nil, "def", "abc"]
[456, 123, nil, nil]
false
I'd expect the last line to be true (that is, the a way and the b way to be
equivalent). Is there something wrong in my expectations?
- Aleksi