I have a variable:
my_arr
which may be nil or an array. I would like to verify if it contains at least one element. It can be accomplished by:
my_arr && !my_arr.empty?
but I want to write it simpler. I tried:
!my_arr.empty?
but it fails if my_arr is nil. Is there a simple way?
my_arr&.empty? == false, which is… not better. Also(my_arr || []).empty?, also not better. Just stick with what you have.niland/orfalsevalues?my_arris always an array. Why should something that is supposed to be an array actually benil?