+ 1
Ruby - Class inheritance - Why is output "PUBGM"?
class Game @@play = "Fortnite" def self.play @@play end end class Mobile_Game < Game @@play = "PUBGM" end puts Game.play
3 Answers
+ 1
Well, but why the subclass one "wins" over the class one?
0
class variable is shared between class and its subclass
0
by testing it, it seems so.
i'm not playing much with ruby