Created
March 15, 2014 23:56
-
-
Save jancantor/d1350ff41e4bca8f8ff6 to your computer and use it in GitHub Desktop.
This file contains 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
# | |
# Expressions & Conditionals | |
# | |
games = ["Super Mario Bros.", "Contra", "Metroid", "Mega Man 2"] | |
# Unless | |
unless games.empty? | |
puts "Games in your vast collection: #{games.count}" | |
end | |
# Inline unless | |
puts "Games in your vast collection: #{games.count}" unless games.empty? | |
# If / Else | |
if games.empty? | |
puts "You don't have games in your collection" | |
else | |
puts "Games in your vast collection: #{games.count}" | |
end | |
# Inline If | |
puts "You don't have games in your collection." if games.empty? | |
# && / "AND" | |
if user && user.signed_in? | |
# Do something here... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment