Forked from activefx/gist:5460d9236ba0ba7f1800
Last active
August 29, 2015 14:18
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