Skip to content

Instantly share code, notes, and snippets.

@kyrylo
Created December 10, 2012 23:07
Show Gist options
  • Save kyrylo/4254201 to your computer and use it in GitHub Desktop.
Save kyrylo/4254201 to your computer and use it in GitHub Desktop.
Empty or not empty
if [].each do |elem|
puts "NOT EMPTY!"
end.empty?
puts "EMPTY!"
end
#EMPTY!
#=> nil
if [:piglet].each do |elem|
puts "NOT EMPTY!"
end.empty?
puts "EMPTY!"
end
# NOT EMPTY!
#=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment