Bird
0
0

Find the error in this Ruby code snippet:

medium📝 Debug Q7 of 15
Ruby - Blocks, Procs, and Lambdas
Find the error in this Ruby code snippet:
array.each do |item|
  puts item
end)
ANo error, code is correct
BExtra closing parenthesis at the end
CIncorrect use of do..end with each
DMissing block parameter pipes
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax carefully

    The code has an extra closing parenthesis after end which is not matched with an opening parenthesis.
  2. Step 2: Confirm block syntax correctness

    The block syntax with do..end and pipes is correct, so the only error is the extra parenthesis.
  3. Final Answer:

    Extra closing parenthesis at the end -> Option B
  4. Quick Check:

    Extra parenthesis error = D [OK]
Quick Trick: Check for unmatched parentheses after blocks [OK]
Common Mistakes:
  • Ignoring extra parentheses
  • Thinking pipes are missing
  • Confusing block syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes