Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created May 28, 2012 18:41
Show Gist options
  • Select an option

  • Save practicingruby/2820589 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/2820589 to your computer and use it in GitHub Desktop.
class A
def initialize
@b = B.new
end
def method_missing(m, *a, &b)
@b.public_send(m, *a, &b) # changing this to use send() fixes the error
end
end
class B
def initialize
@c = C.new
end
def method_missing(m, *a, &b)
@c.public_send(m, *a, &b)
end
end
class C
def fritos
yield
puts " DISGUSTING!"
end
end
A.new.fritos { puts "ARE" } #=> FAIL
=begin
wtf.rb:26:in `fritos': no block given (yield) (LocalJumpError)
from wtf.rb:19:in `public_send'
from wtf.rb:19:in `method_missing'
from wtf.rb:8:in `public_send'
from wtf.rb:8:in `method_missing'
from wtf.rb:31:in `<main>'
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment