Complete the code to define a module named MathTools.
module [1] def self.square(x) x * x end end
The module name should be MathTools to match the intended namespace.
Complete the code to call the square method inside the MathTools module.
result = MathTools.[1](5) puts result
The method defined in the module is named square, so we call MathTools.square(5).
Fix the error in the code by completing the module namespace correctly.
module Geometry module [1] def self.area(radius) 3.14 * radius * radius end end end
Module names should be capitalized and plural if representing a collection, so Shapes is correct.
Fill both blanks to define a nested module and call its method correctly.
module [1] module Calculator def self.add(a, b) a + b end end end result = [2]::Calculator.add(3, 4) puts result
The outer module is MathTools, and to call the nested method, use MathTools::Calculator.add.
Fill all three blanks to create a nested module with a method and call it properly.
module [1] module [2] def self.greet(name) "Hello, #{name}!" end end end message = [3]::Greeter.greet("Alice") puts message
The outer module is MyApp, the nested module is Greeter, and the call uses MyApp::Greeter.greet.