-
-
Save mpalmer/7297631d4236479744da 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 Example | |
def make_method(&block) | |
@block = block | |
end | |
def dynamic_method(n) | |
@block.call(n) if @block | |
end | |
end | |
example = Example.new | |
example.make_method do |n| | |
n + 1 | |
end | |
if example.dynamic_method(1) == 2 | |
puts "OK" | |
else | |
puts "FAIL" | |
puts "Expected 2, got #{example.dynamic_method(1).inspect}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment