Welcome to the Treehouse Community
Looking to learn something new?
Pushing an instance variable to a class variable?
I just went through the Methods deep dive and feel I am getting a good understanding of what was going on. I am trying to add something to my BankAccount class. We make a create_for Class method, but if we were to create an instance of the class without using the class method, lets say it is:
new_account = BankAccount.new("joe","namath")
we would create a new instance of the Class BankAccount BUT it is not added in our array @accounts. The only way of getting it into this would be using .create_for
How can I append/add new_account into the @accounts array?
Jason SeiferTreehouse Guest Teacher
Hey Scooter D you're absolutely right! In this instance, we're defining an interface of our BankAccount class to work a certain way. You could also append that instance in the initialize method if you chose. In this case, if you're working with a lot of people on this project, you'd want to document why you did it and attempt to make people follow that API.