When running trough a collection in the view you can do:
<% @foo.each do |bar|
#Do stuff
<% end.empty? %>
#if empty stuff
<% end %>
This is really really nice for the view, but i cant seem to find a way for rake tasks, or other ruby related code.
Is there a nice ruby way of doing this?
EDIT: Solution by @meagar http://rubyfiddle.com/riddles/6d37b/2 Forgot the if
if foo.each do |bar|
puts "Bar #{bar}"
end.empty?
puts "Foo is empty"
end