-
-
Save comatory/1ec93c5791052e3ea5e7 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' | |
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 | |
puts john.class.class_variable | |
john.class.class_variable = 'bye' # this will give you an error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment