Skip to content

Instantly share code, notes, and snippets.

@waseem
Created September 28, 2014 04:57
Show Gist options
  • Save waseem/1fc42d297db978ea3488 to your computer and use it in GitHub Desktop.
Save waseem/1fc42d297db978ea3488 to your computer and use it in GitHub Desktop.
irb(main):001:0> class Fookamachi
irb(main):002:1> def hackety_hack
irb(main):003:2> proc do
irb(main):004:3* def hello
irb(main):005:4> 'hello'
irb(main):006:4> end
irb(main):007:3> end
irb(main):008:2> end
irb(main):009:1> end
=> :hackety_hack
irb(main):010:0> fooka = Fookamachi.new
=> #<Fookamachi:0x007fba6b078410>
irb(main):011:0> fooka.hackety_hack
=> #<Proc:0x007fba6b05a348@(irb):3>
irb(main):012:0> fooka.hackety_hack.hello
NoMethodError: undefined method `hello' for #<Proc:0x007fba6b04a9c0@(irb):3>
from (irb):12
from /Users/waseem/.rubies/ruby-2.1.2/bin/irb:11:in `<main>'
irb(main):013:0> fooka.hello
NoMethodError: undefined method `hello' for #<Fookamachi:0x007fba6b078410>
from (irb):13
from /Users/waseem/.rubies/ruby-2.1.2/bin/irb:11:in `<main>'
irb(main):014:0> fooka.hackety_hack.call.hello
NoMethodError: undefined method `hello' for :hello:Symbol
from (irb):14
from /Users/waseem/.rubies/ruby-2.1.2/bin/irb:11:in `<main>'
irb(main):015:0> fooka.hackety_hack.call
=> :hello
irb(main):016:0> o = Object.new
=> #<Object:0x007fba6c036b18>
irb(main):017:0> o.instance_eval(&fooka.hackety_hack)
=> :hello
irb(main):018:0> o.hello
=> "hello"
irb(main):019:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment