Is it ok to use `any?` to check if an array is not empty?

any? isn’t the same as not empty? in some cases.

>> [nil, 1].any?
=> true
>> [nil, nil].any?
=> false

From the documentation:

If the block is not given, Ruby adds
an implicit block of {|obj| obj} (that
is any? will return true if at least
one of the collection members is not
false or nil).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)