using module function in main ruby

module MathFunctions
  def self.double(var)
    var * 2
  end

  def self.triple(var)
    var * 3
  end
end

puts MathFunctions.double(5) # Output: 10
puts MathFunctions.triple(3) # Output: 9

Explanation:

  1. module MathFunctions: Defines a module named MathFunctions.

  2. def self.double(var): Defines a method double inside the MathFunctions module that takes a parameter var.

  3. var * 2: Multiplies the var parameter by 2.

  4. end: Ends the double method definition.

  5. def self.triple(var): Defines a method triple inside the MathFunctions module that takes a parameter var.

  6. var * 3: Multiplies the var parameter by 3.

  7. end: Ends the triple method definition.

  8. puts MathFunctions.double(5): Calls the double method from the MathFunctions module with an argument of 5 and prints the result, which is 10.

  9. puts MathFunctions.triple(3): Calls the triple method from the MathFunctions module with an argument of 3 and prints the result, which is 9.