Is there a Rails/Ruby idiom for checking if an enumerable is both present and has non-
if foo && foo.any?
You can use the
try method provided by ActiveSupport:
This will evaluate to
obj.nil? or to
obj is an empty collection, so in both cases it will evaluate to a falsy value in a boolean context.