Last active
March 6, 2017 20:38
-
-
Save joecorcoran/3470b6e1e6a506705a9c6417a194c8ae to your computer and use it in GitHub Desktop.
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
# Use all examples to output the string "Hello, Sven!" | |
def hello_0(&block) | |
puts yield | |
end | |
def hello_1(&block) | |
puts block.call | |
end | |
def hello_2(name, &block) | |
puts block.call(name) | |
end | |
class Hello3 | |
def initialize(name) | |
@name = name | |
end | |
def call(&block) | |
puts self.instance_exec(&block) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment