Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Ruby Objects and Classes!
You have completed Ruby Objects and Classes!
Preview
We're going to be creating a class that will approximate a bank account. In this first video, we'll lay the groundwork for our program and define the class and an internal variable.
Code Samples
class BankAccount
def initialize(name)
@name = name
@transactions = []
end
end
bank_account = BankAccount.new("Jason")
puts bank_account.inspect
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
So far we've learned about how to write
classes and methods.
0:00
We've also learned about the different
kinds of variables we can use in
0:00
our classes.
0:03
Let's put it all together and write the
simple bank account class.
0:05
We're going to be using all of the classes
we've learned about so far.
0:09
String, numbers, arrays and more.
0:13
We'll be doing all of this inside
workspaces, so let's get to it.
0:16
Okay, so let's go ahead and create our
bank account class.
0:21
So, let's go to the File > New File.
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up