Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Banking on Ruby

Creating the Account Class

We'll start off by creating our Account class. First, though, you probably noticed this bit of fanciness in the last exercise:

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

What's that balance=100 doing? It's signifying an optional parameter. Ruby is saying that you can pass one or two arguments to initialize; if you pass two, it uses your balance argument to set @balance; if you only pass a name, balance gets a default value of 100, and that's what gets stored in @balance.

You probably also noticed we used underscores in our 1_000_000 (one million). Ruby allows this, and it makes it easier to read big numbers! Cool, no?

Report a Bug
If you see a bug or any other issue with this page, please report it here.