Skip to content

Instantly share code, notes, and snippets.

@sfgeorge
Last active August 29, 2015 13:57
Show Gist options
  • Save sfgeorge/9604050 to your computer and use it in GitHub Desktop.
Save sfgeorge/9604050 to your computer and use it in GitHub Desktop.
WAT
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
@sfgeorge
Copy link
Author

  • In terms of output, the methods all_or_nothing_a and all_or_nothing_b are equivalent to all_or_nothing_c.
  • One deviation of internal functionality is that all_or_nothing_b never invokes value, whereas a and c do.

@Jared-Prime
Copy link

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