Last active
January 2, 2018 04:09
-
-
Save ryanckulp/ee3a4ee3de573f5f4c0182dc2689a86c to your computer and use it in GitHub Desktop.
intuitive use case for unless...end statement in Ruby
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
require 'date' | |
def date_night? | |
Date.today.wday == 5 # friday | |
end | |
unless date_night? | |
puts "study hard!" | |
end | |
# shorthand also works... | |
puts "study hard!" unless date_night? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment