Created
December 2, 2012 20:47
-
-
Save alindeman/4190985 to your computer and use it in GitHub Desktop.
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
class Foo | |
def bar | |
"wtf?" | |
end | |
protected :bar | |
def invoke_bar | |
public_send(:bar) | |
end | |
end | |
puts Foo.public_send(:bar) rescue puts "error; this seems normal" | |
puts Foo.new.invoke_bar | |
# The last statement outputs "wtf?" on: | |
# * 1.9.3p194 | |
# * 1.9.3p327 | |
# The last statement raises a NoMethodError on: | |
# * JRuby 1.7.0 | |
# * rubinius 2.0.0dev 2279857e | |
# | |
# I /expected/ the NoMethodError behavior |
+1 to myron, though it does work as you'd expect even if you do that (NoMethodError exception).
BTW, this was a bug in Rubinius until several months ago too: jfirebaugh/rubinius@b3a4533
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't line 12 be
Foo.new.public_send(:bar)
? You haven't defined a class methodbar
.