переменная класса Ruby
class Customer
@@no_of_customers = 0
end
Clumsy Caterpillar
class Customer
@@no_of_customers = 0
end
class Dog # Initialize class!
def initialize(name) # Initialize function of class Dog
@name = name # Set name to param in class
end
def print_name() # Function to print out the name in params
puts @name # Puts!
end
end
my_dog = Dog.new "Bruno" # Create class and save it in variable
my_dog.print_name # Call print_name function from class
# Output:
# Bruno