Last active
February 28, 2019 12:51
-
-
Save DazWorrall/505b9b717957549ef94957c5383e2add to your computer and use it in GitHub Desktop.
This inheritance behaviour gets me every time
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
class Foo | |
A = true | |
def m | |
A | |
end | |
def n | |
self.class::A | |
end | |
end | |
class Bar < Foo | |
A = false | |
end | |
puts Bar.new.m # true | |
puts Bar.new.n # false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment