ruby's "any?" and "all?" methods behaviour on Empty Arrays and Hashes ruby's "any?" and "all?" methods behaviour on Empty Arrays and Hashes ruby ruby

ruby's "any?" and "all?" methods behaviour on Empty Arrays and Hashes


The method returns true if the block never returns false or nil.

So since the block never gets called, of course it never returns false or nil, thus all returns true.

The same goes for any:

The method returns true if the block ever returns a value other than false or nil.

Since the block never gets called, it never returns a value other than false or nil, thus any returns false.