Skip to content

Instantly share code, notes, and snippets.

@gabetax
Created January 13, 2014 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabetax/8394067 to your computer and use it in GitHub Desktop.
Save gabetax/8394067 to your computer and use it in GitHub Desktop.
Hacky alternative to ruby not having each/else. Object#presence provided by active_support.
a = %w(a b c)
a.each do |i|
puts i
end.presence || puts("the array was empty")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment