Skip to content

Instantly share code, notes, and snippets.

@reinh
Created June 16, 2010 20:29
Show Gist options
  • Save reinh/441221 to your computer and use it in GitHub Desktop.
Save reinh/441221 to your computer and use it in GitHub Desktop.
class Foo
def initialize(counter)
@counter = 0
instance_eval "def #{counter}; @counter; end"
end
def call
@counter += 1
yield
end
end
a = Foo.new(:foo)
a.call { puts "hi" }
a.foo
a.call { puts "hi" }
a.foo
a.call { puts "hi" }
a.foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment