The documentation for Enumerable#find
/#detect
says:
find(ifnone = nil) { |obj| block } → obj or nil
find(ifnone = nil) → an_enumerator
Passes each entry in enum to block. Returns the first for which block is not false. If no object matches, calls ifnone and returns its result when it is specified, or returns
nil
otherwise.
However, when it is called on the Hash, the result has changed the type to Array instead of the original Hash.
Is it some implementation fault or some historical conventions regarding this datatype?
{a: 'a', b:'b'}.find {|k, v| v == 'b'}
# => [:b, 'b']