-
-
Save karapetyan/70d82b42906f788ae1fb 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 Customer | |
attr_reader :name | |
def initialize(name) | |
@name = name # @name instance variable, cause it's created when instance initialized | |
end | |
@class_variable = 'hello' #=> also class variable :P | |
def self.class_variable | |
@class_variable | |
end | |
end | |
peter = Customer.new("Peter") | |
john = Customer.new("John") | |
puts peter.name | |
puts john.name | |
puts peter.class.class_variable # will return a same value! | |
puts john.class.class_variable # will return a same value! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment