Skip to content

Instantly share code, notes, and snippets.

@abscondment
Created January 7, 2011 01:35
Show Gist options
  • Save abscondment/768965 to your computer and use it in GitHub Desktop.
Save abscondment/768965 to your computer and use it in GitHub Desktop.
class Foo
attr_accessor :bar
def initialize
@bar = 'init'
end
def fun
lambda { "got: #{@bar}" }
end
def fun2
b = @bar
lambda { "got: #{b}" }
end
end
def try_me(fn)
fn.call
end
foo = Foo.new
puts try_me(foo.fun)
puts try_me(foo.fun2)
fn = foo.fun
foo.bar = 'newbar'
puts fn.call
puts try_me(fn)
puts try_me(foo.fun)
puts try_me(foo.fun2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment