Skip to content

Instantly share code, notes, and snippets.

@everm1nd
Last active October 27, 2017 10:40
Show Gist options
  • Save everm1nd/78d353dff1ad6fe8c210ad9899352da9 to your computer and use it in GitHub Desktop.
Save everm1nd/78d353dff1ad6fe8c210ad9899352da9 to your computer and use it in GitHub Desktop.
# this works, because `proc === x` is same as `proc.call(x)`
# weird syntactic choice makes a great job in case statements
def say_something_about(number)
greater_then_10 = -> (number) { number > 10 }
equals_15 = -> (number) { number === 15 }
case number
when greater_then_10
puts "it's greater then 10!"
when equals_15
puts "it equals 15!"
else
puts "it's #{number}"
end
end
say_something_about 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment