Created
February 17, 2012 21:40
-
-
Save ileitch/1855618 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
| require 'delegate' | |
| class Foo | |
| def me | |
| puts "meee" | |
| end | |
| end | |
| foo = Foo.new | |
| delegator = SimpleDelegator.new(foo) | |
| m = delegator.method(:me) | |
| p m | |
| delegator.__setobj__([1,2,3]) | |
| m.call | |
| # MRI: Note inspect says the method is defined on SimpleDelegator. | |
| # #<Method: SimpleDelegator#me> | |
| # trust.rb:14:in `call': undefined method `me' for [1, 2, 3]:SimpleDelegator (NoMethodError) | |
| # from trust.rb:14:in `<main>' | |
| # I can achieve the same looking #inspect in rbx with: | |
| # | |
| # cm = Rubinius.find_method(foo, :me) | |
| # Method.new(delegator, cm[1], cm[0], :me) <-- Note receiver argument. | |
| # | |
| # However the call is still made to the compiled method, m[0]. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment