-
-
Save practicingruby/2820589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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