Skip to content

Instantly share code, notes, and snippets.

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