Last active
September 24, 2015 08:54
-
-
Save karapetyan/b9006684a11bbfb5bc17 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 | |
@class_variable = "hello" #instance class varaible, cause self => customer.class | |
def self.show | |
@class_variable | |
end | |
def initialize(name) | |
@name = name # @name instance variable, cause it's created when instance initialized | |
end | |
end | |
puts Customer.show | |
peter = Customer.new("Peter") | |
# peter.show #=> error, cause instances can't access to class methods | |
puts peter.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment