ruby class variable
class Customer
@@no_of_customers = 0
end
ruby class variable
class Customer
@@no_of_customers = 0
end
ruby class
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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us