Dear all,

Enumerable#select always returns an array. On a hash too, it returns
an array of arrays of key-value pairs.

The issue with this approach is that 'select' calls cannot be chained.
It is now mandatory to know whether the receiver is the original hash
or is the result of at least one 'select'.

Thus, for 'select'ing a second (or subsequent) time, the semantics of
the block themselves have to change.

Else, the result of the first selection has to be manually converted
to a hash (may be using something like hsh =
Hash[select_result.flatten]).

Is there some reason why when a filter is applied to a hash, we get an
object of a different type?

This is not so much an issue, semantically, with Set instances, though
the principle applies there, as well.

Wouldn't it be good if application of a filter on an object of a given
type results in an object of the same type?

Best regards,

JS