DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

If Else For Each Without Writing Extra Lines!

12.11.2009
| 3733 views |
  • submit to reddit
        
a = [1, 2]

if a.each do |i|
  puts i
end.empty?
  puts "Empty"
end

<a href="http://www.freezzo.com">http://www.freezzo.com</a>