FAQ: Banking on Ruby - Creating the Account Class

This community-built FAQ covers the “Creating the Account Class” exercise from the lesson “Banking on Ruby”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Ruby

FAQs on the exercise Creating the Account Class

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

hi!
while creating my class Account, I had a typed Acount by mistake and the program didn’t run because of the typo.

I thought we could give any name to a class (wasn’t on purpose), so why’s that? I’m pretty confused right now ó.ò

Hello,

Well this is simply because the exercises will need to validate your code to let you move to the next step. So the program will check that you respected the guidelines. That’s actually pretty neat. It requires of you to be careful while coding and to double-check your work for errors.

Outside of Codecademy, you’ll be able to name your classes whatever you like.

2 Likes

Hi everyone!

I don’t under stand why we would want balance to have a default value of 100, Can someone please explain?

Thanks.

Hi everyone!

I’m confused here. I thought the point of or attr_reader was so we didn’t have to write out all of the code in the method ?

Can someone please explain?

The code that attr_reader is saving you from having to write is

  def name
    @name
  end

  def balance
    @balance
  end

It is still necessary to write this in the initialize method:

def initialize(name, balance=100)
    @name = name
    @balance = balance
  end

Regarding the previous question - suppose the account required a starting deposit of 100; it could make sense as a default value in this case, but it seems to be an arbitrary example here. It’s optional to include, or could be set to another value.