Bird
0
0

Which of the following is a syntax error when declaring a module in Ruby?

easy📝 Syntax Q12 of 15
Ruby - Modules and Mixins
Which of the following is a syntax error when declaring a module in Ruby?
Amodule Tools { def help end }
Bmodule Tools def self.help end end
Cmodule Tools end
Dmodule Tools CONSTANT = 10 end
Step-by-Step Solution
Solution:
  1. Step 1: Check Ruby module block delimiters

    Ruby modules use module ... end without braces { }.
  2. Step 2: Identify invalid syntax

    module Tools { def help end } uses braces { } which is invalid syntax for module declaration in Ruby.
  3. Final Answer:

    module Tools { def help end } -> Option A
  4. Quick Check:

    Ruby modules use 'module ... end', not braces [OK]
Quick Trick: Ruby modules never use curly braces for blocks [OK]
Common Mistakes:
  • Using curly braces instead of 'end'
  • Missing 'end' keyword
  • Confusing module with class syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes