Skip to content

Instantly share code, notes, and snippets.

@jwilger
Created July 28, 2012 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwilger/3192103 to your computer and use it in GitHub Desktop.
Save jwilger/3192103 to your computer and use it in GitHub Desktop.
Sometimes I Hate Ruby
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