This is my first attempt with Ruby on Rails, so I apologize if the question is obvious, but unfortunately I can not find the answer anywhere.
class Client < Person
clientList = []
def initialize(name, surname, email, wallet)
super(name, surname, email)
@wallet = wallet
end
attr_reader :wallet, :clientList
def to_s
super + ", #{@wallet}"
end
def add_to_array
clientList + this.object
#i know its not correct
end
end
I would like to create method, which allow me to add instances of client class to clientList array. What else is there later any option to use this method already in def initialize(name, surname, email, wallet). Something like this.add_to_array
I would like to have array with all clients inside, but i don't want to use method add_to_array everytime i create new client. It should be automatic.