Skip to content

Instantly share code, notes, and snippets.

@takkanm
Created September 24, 2011 13:57
Show Gist options
  • Select an option

  • Save takkanm/1239351 to your computer and use it in GitHub Desktop.

Select an option

Save takkanm/1239351 to your computer and use it in GitHub Desktop.
ruby-1.9.2-p290 :001 > o = Object.new
=> #<Object:0x007fb4ea0615e8>
ruby-1.9.2-p290 :002 > o.instance_eval {|obj| p obj; p self }
#<Object:0x007fb4ea0615e8>
#<Object:0x007fb4ea0615e8>
=> #<Object:0x007fb4ea0615e8>
ruby-1.9.2-p290 :003 > o.instance_exec {|obj| p obj; p self }
nil
#<Object:0x007fb4ea0615e8>
=> #<Object:0x007fb4ea0615e8>
ruby-1.9.2-p290 :004 > o.instance_exec(1) {|obj| p obj; p self }
1
#<Object:0x007fb4ea0615e8>
=> #<Object:0x007fb4ea0615e8>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment