Recall & Review
beginner
What does the 'Everything is an object' mental model mean in Ruby?
In Ruby, everything you work with is an object. Numbers, strings, methods, and even classes themselves are objects. This means they all have methods and properties you can use.
Click to reveal answer
beginner
How can you call a method on a number in Ruby?
Since numbers are objects, you can call methods on them like this:
5.next which returns 6.Click to reveal answer
intermediate
Are classes in Ruby objects too?
Yes! Classes in Ruby are objects of the class Class. This means you can call methods on classes themselves.Click to reveal answer
beginner
What is the class of a string like "hello" in Ruby?The class of "hello" is String. You can check this by calling <code>"hello".class</code> which returns <code>String</code>.Click to reveal answer
intermediate
Why is the 'Everything is an object' model helpful?
It helps you understand that you can use methods on any value, making Ruby very consistent and flexible. It also means you can extend or change behavior by adding methods to objects.
Click to reveal answer
In Ruby, what is the class of the number 10?
✗ Incorrect
In modern Ruby, 10 is an Integer object. Fixnum was used in older versions but now Integer covers all whole numbers.
Which of these is NOT true about Ruby's 'Everything is an object' model?
✗ Incorrect
In Ruby, everything is an object, not just strings and arrays.
What will
"hello".class return in Ruby?✗ Incorrect
The class of a string literal is String.
Which class do all Ruby classes belong to?
✗ Incorrect
All classes in Ruby are instances of the Class class.
What does calling
5.next return in Ruby?✗ Incorrect
Since 5 is an object, calling the next method returns the next integer, 6.
Explain the 'Everything is an object' mental model in Ruby and give two examples.
Think about how you can call methods on numbers and strings.
You got /3 concepts.
Why does Ruby treat classes as objects? How does this affect how you use classes?
Consider how classes themselves can have methods.
You got /3 concepts.