Bird
0
0

What is wrong with this module declaration?

medium📝 Debug Q7 of 15
Ruby - Modules and Mixins
What is wrong with this module declaration?
module Tools
  def use
    puts "Using tools"
  end
end

Tools.use
AMissing parentheses in method call
BMethod should be defined with self. prefix
CModule name should be lowercase
DCalling instance method on module without including it
Step-by-Step Solution
Solution:
  1. Step 1: Understand method type

    The method use is an instance method inside the module.
  2. Step 2: Calling instance method on module

    Calling Tools.use tries to call a module method, but use is not defined as a module method or included in a class, causing error.
  3. Final Answer:

    Calling instance method on module without including it -> Option D
  4. Quick Check:

    Instance methods need inclusion; module methods use self. prefix [OK]
Quick Trick: Instance methods require inclusion; module methods use self. prefix [OK]
Common Mistakes:
  • Calling instance methods directly on module
  • Thinking method call needs parentheses
  • Believing module names must be lowercase

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes