Skip to content

Instantly share code, notes, and snippets.

@niku
Created September 6, 2011 10:12
Show Gist options
  • Save niku/1197188 to your computer and use it in GitHub Desktop.
Save niku/1197188 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
class Foo
a=1 # インスタンス変数じゃない!
define_method(:bar, lambda{ a+=1 })
end
f = Foo.new
f.bar # => 2
f.bar # => 3
f.bar # => 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment