-
-
Save jasonswett/9808c02f7add3e0c3837adba53ce44f4 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
class Greeter | |
def greet(name) | |
"Hello #{name}" | |
end | |
end | |
class User | |
def first_name | |
"Foo" | |
end | |
def greet_with(&block) | |
Greeter.new.instance_exec(&block) | |
end | |
def greet_first_name | |
p = Proc.new { first_name } | |
greet_with { greet(p.call) } | |
end | |
end | |
puts User.new.greet_first_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment