Created
May 9, 2018 11:21
-
-
Save taq/828311b6c998fafce9c2c9cc90efb2a5 to your computer and use it in GitHub Desktop.
Ruby class variable
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 | |
class << self | |
attr_reader :ivar | |
end | |
@ivar = 'Hello!' | |
end | |
class Bar < Foo | |
@ivar = 'World' | |
end | |
class Baz < Foo | |
@ivar = 'Underworld' | |
end | |
puts Baz.ivar | |
puts Bar.ivar | |
puts Foo.ivar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment