0
0
Rubyprogramming~5 mins

Everything is an object mental model in Ruby - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AInteger
BNumber
CFixnum
DObject
Which of these is NOT true about Ruby's 'Everything is an object' model?
AClasses themselves are objects.
BOnly strings and arrays are objects.
CYou can call methods on numbers.
DEven true and false are objects.
What will "hello".class return in Ruby?
AClass
BObject
CText
DString
Which class do all Ruby classes belong to?
AClass
BObject
CModule
DString
What does calling 5.next return in Ruby?
A7
B5
C6
DError
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.