Skip to content

Instantly share code, notes, and snippets.

@ryanckulp
Last active January 2, 2018 04:09
Show Gist options
  • Save ryanckulp/ee3a4ee3de573f5f4c0182dc2689a86c to your computer and use it in GitHub Desktop.
Save ryanckulp/ee3a4ee3de573f5f4c0182dc2689a86c to your computer and use it in GitHub Desktop.
intuitive use case for unless...end statement in Ruby
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