Skip to content

Instantly share code, notes, and snippets.

@karapetyan
Last active September 24, 2015 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save karapetyan/b9006684a11bbfb5bc17 to your computer and use it in GitHub Desktop.
Save karapetyan/b9006684a11bbfb5bc17 to your computer and use it in GitHub Desktop.
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