Last active
August 29, 2015 13:57
-
-
Save sfgeorge/9604050 to your computer and use it in GitHub Desktop.
WAT
This file contains hidden or 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
def all_or_nothing_a(value) | |
if value.eql? :all | |
'You win!' | |
elsif | |
value | |
end | |
end | |
def all_or_nothing_b(value) | |
if value.eql? :all | |
'You win!' | |
end | |
end | |
def all_or_nothing_c(value) | |
if value.eql? :all | |
'You win!' | |
elsif value | |
nil | |
end | |
end | |
all_or_nothing_a :all | |
# => "You win!" | |
all_or_nothing_b :all | |
# => "You win!" | |
all_or_nothing_c :all | |
# => "You win!" | |
all_or_nothing_a "Better luck next time" | |
# => nil | |
all_or_nothing_b "Better luck next time" | |
# => nil | |
all_or_nothing_c "Better luck next time" | |
# => nil |
I don't understand what's surprising here. There's no return value specified for all_or_nothing_a
, so I'd expect it to be nil
. Unless I'm missing something?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
value
, whereas a and c do.