Created
August 14, 2013 01:45
-
-
Save xeqi/6227351 to your computer and use it in GitHub Desktop.
bob exercism
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
class Bob | |
def hey(message) | |
behaviors = { | |
-> {message.nil? || message.strip.empty?} => 'Fine. Be that way!', | |
-> {message.upcase == message} => 'Woah, chill out!', | |
-> {message[-1].chr == '?'} => 'Sure.' | |
} | |
behaviors.fetch(behaviors.keys.find(&:call), "Whatever.") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment