Recall & Review
beginner
What is an Integer in Ruby?
An Integer is a whole number without a decimal point, like 5 or -10.
Click to reveal answer
beginner
What is a Float in Ruby?
A Float is a number with a decimal point, like 3.14 or -0.5.
Click to reveal answer
beginner
How do you write a negative Float number in Ruby?
You write a minus sign before the number, like -2.75.
Click to reveal answer
intermediate
What happens if you divide two Integers in Ruby using `/`?
Ruby returns an Integer result if the division is not exact. For example, 5 / 2 returns 2.
Click to reveal answer
beginner
How can you check the type of a number in Ruby?
Use the `.class` method. For example, `5.class` returns Integer, and `3.14.class` returns Float.
Click to reveal answer
Which of these is an Integer in Ruby?
✗ Incorrect
42 is a whole number without a decimal point, so it is an Integer.
What type does Ruby assign to the number 6.0?
✗ Incorrect
6.0 has a decimal point, so Ruby treats it as a Float.
What is the result type of 7 / 3 in Ruby?
✗ Incorrect
Ruby returns an Integer (2) when dividing two Integers with `/`.
How do you find out if a number is an Integer or Float in Ruby?
✗ Incorrect
The `.class` method returns the type of the object in Ruby.
Which of these is NOT a valid Float in Ruby?
✗ Incorrect
7 is an Integer, not a Float, because it has no decimal point.
Explain the difference between Integer and Float number types in Ruby.
Think about numbers with and without decimals.
You got /4 concepts.
How can you check the type of a number in Ruby and why is it useful?
Use a method that tells you the object's class.
You got /3 concepts.