How to correctly check for filled array
Do you know the opposite of empty?
arr = ['array', 'with', 'stuff', 'in', 'it']
instead of
unless arr.empty?
# do stuff
end
use
if arr.any?
# do stuff
end
Check out the gist for details
Written by Leif Gensert
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#