Created
January 29, 2013 23:02
-
-
Save ushis/4668824 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
#!/usr/bin/env ruby | |
puts "ruby #{RUBY_VERSION}" | |
class A | |
def a | |
if respond_to?(:b) | |
puts "I am responding to b." | |
else | |
puts "I am not responding to b." | |
end | |
begin | |
b | |
rescue NoMethodError | |
puts "I can not call b." | |
end | |
end | |
end | |
class B < A | |
protected | |
def b | |
puts "I can call b." | |
end | |
end | |
B.new.a | |
# ruby 2.0.0 | |
# I am not responding to b. | |
# I can call b. | |
# | |
# ruby 1.9.3 | |
# I am responding to b. | |
# I can call b. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment