Bird
0
0

Identify the problem in this Ruby code:

medium📝 Debug Q7 of 15
Ruby - Control Flow
Identify the problem in this Ruby code:
score = 50
case score
in 0..49 puts 'Fail'
in 50..100 then puts 'Pass'
end
AVariable <code>score</code> is undefined
BRange 0..49 is invalid
CNo problem; code runs correctly
DMissing <code>then</code> after first <code>in</code> pattern
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of in patterns

    The first in pattern lacks the then keyword after the range.
  2. Step 2: Confirm correct syntax

    Each in pattern should be followed by then before the action.
  3. Final Answer:

    Missing then after first in pattern -> Option D
  4. Quick Check:

    in patterns need then [OK]
Quick Trick: Always add then after in patterns [OK]
Common Mistakes:
  • Omitting then
  • Assuming ranges are invalid
  • Confusing when and in

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes