0
0
Rubyprogramming~5 mins

Until loop in Ruby - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does an until loop do in Ruby?
An until loop repeats the code inside it as long as the condition is false. It stops when the condition becomes true.
Click to reveal answer
beginner
How is an until loop different from a while loop?
An until loop runs while the condition is false, but a while loop runs while the condition is true. They are opposites.
Click to reveal answer
beginner
Write a simple Ruby until loop that prints numbers from 1 to 5.
number = 1 until number > 5 puts number number += 1 end
Click to reveal answer
beginner
Can an until loop run zero times? When?
Yes, if the condition is already true at the start, the until loop will not run at all.
Click to reveal answer
beginner
What keyword ends an until loop block in Ruby?
The end keyword is used to close the until loop block.
Click to reveal answer
What condition does an until loop check to continue running?
ACondition is zero
BCondition is true
CCondition is nil
DCondition is false
Which keyword ends an until loop in Ruby?
Aend
Bstop
Cfinish
Dclose
What will this code print?
count = 3
until count > 5
  puts count
  count += 1
end
A3 4
B4 5
C3 4 5
DNothing
If the condition is true at the start, how many times does an until loop run?
AOnce
BZero times
CInfinite times
DTwice
Which loop is the opposite of until in Ruby?
A<code>while</code>
B<code>loop</code>
C<code>for</code>
D<code>each</code>
Explain how an until loop works in Ruby and give a simple example.
Think about repeating something until a condition becomes true.
You got /3 concepts.
    Compare until and while loops in Ruby. When would you use each?
    They are opposites but both repeat code based on conditions.
    You got /3 concepts.