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 Blocks!
You have completed Ruby Blocks!
Preview
In this stage, we'll be working towards creating our own class that uses blocks, arrays, hashes, and more. In this video, we'll create the shell class that will hold our monster.
Code Samples
class Monster
attr_reader :name
def initialize(name)
@name = name
end
end
Here's how we can initialize it:
monster = Monster.new("Fluffy")
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
Now we're going to put all of
that knowledge to the test and
0:00
write a program using work spaces.
0:03
We'll be working with Ruby's built in
classes, writing our own classes and
0:05
methods, and practicing with blocks.
0:09
So let's go ahead and get started.
0:12
Okay, so let's go ahead and
create our own class that uses blocks and
0:14
hashes and strings and
everything we've learned so far.
0:19
What we're going to do is make a class for
a monster.
0:23
And a monster is going to be able
to do a few different things.
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