Created
January 13, 2014 03:03
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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