Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Help with Bank accounts
Create an initialize method for the BankAccount class that takes one argument, name, which sets @name as an instance variable on initialization.
BankAccount = Class.new BankAccount = Class.new
Jeff MudayTreehouse Moderator 26,933 Points
You might want to re-watch the video explaining Ruby classes. Ruby is a very nicely laid out and logical language. It is worthwhile to learn and Treehouse has some great courses to learn it!
To define a class in Ruby, you use the "class" keyword and make sure to use the "end" keyword to make the closure of the class.
class BankAccount end
The second part of the challenge is asking for you to create a function called "initialize" for BankAccount.
1 The "initialize" needs to accept a parameter called "name".
2 the parameter needs to be assigned to the class variable name (@name)
3 finally, create a new class array called @transactions
class BankAccount def initialize(name) @name = name @transactions = Array.new end end