The source code to demonstrate a simple module is given below. The given program is compiled and executed successfully.
# Ruby program to demonstrate
# a simple module
module MyModule
def MyModule.Method1
puts "Inside Method1";
end
def MyModule.Method2
puts "Inside Method2";
end
def MyModule.Method3
puts "Inside Method3";
end
end
MyModule.Method1();
MyModule.Method2();
MyModule.Method3();
Output:
Inside Method1
Inside Method2
Inside Method3
Explanation:
In the above program, we created a module MyModule. Then we defined 3 methods Method1, Method2, and Method3 inside the created module. After that, we called all defined methods and printed appropriate messages.
Program/Source Code:
The source code to demonstrate a simple module is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created a module MyModule. Then we defined 3 methods Method1, Method2, and Method3 inside the created module. After that, we called all defined methods and printed appropriate messages.
need an explanation for this answer? contact us directly to get an explanation for this answer