Last active
March 28, 2017 20:03
-
-
Save chrisfarber/0cae4f66de7194f3c42837931e151913 to your computer and use it in GitHub Desktop.
exploring ruby's nuances
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
module Thing | |
module_function | |
def thing(&block) | |
(1..3).map(&block) | |
end | |
def other_thing | |
thing do |v| | |
next(:surprise) if v == 2 | |
v | |
end | |
end | |
def other_other_thing | |
thing do |v| | |
return(:surprise) if v == 3 | |
v | |
end | |
end | |
end | |
puts(Thing.other_thing.inspect) # output: [1, :surprise, 3] | |
puts(Thing.other_other_thing.inspect) # output: :surprise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment