Created
July 28, 2012 06:32
-
-
Save jwilger/3192103 to your computer and use it in GitHub Desktop.
Sometimes I Hate Ruby
This file contains 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 select | |
'Foo#select' | |
end | |
end | |
class Bar < SimpleDelegator | |
def a | |
self.select | |
end | |
def b | |
select | |
end | |
end | |
foo = Foo.new | |
bar = Bar.new(foo) | |
# This call works as you would expect | |
puts bar.a | |
# This call results in an exception, because it actually invokes Kernel#select instead of Foo#select | |
puts bar.b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment