Skip to content

Instantly share code, notes, and snippets.

@joecorcoran
Last active March 6, 2017 20:38
Show Gist options
  • Save joecorcoran/3470b6e1e6a506705a9c6417a194c8ae to your computer and use it in GitHub Desktop.
Save joecorcoran/3470b6e1e6a506705a9c6417a194c8ae to your computer and use it in GitHub Desktop.
# 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