Saved Bookmarks
| 1. |
What is a module? |
|
Answer» A module in ruby has multiple method implementations, various constants, and different class variables. Modules are DEFINED similarly to a class with a module keyword.
Syntax: module Module_name # statements to be executed end For example: # Creating a module with name Hello module Hello # PREFIX with the name of the Module # module method def Hello.welcome puts “Hello!! Welcome” End end # calling the methods of the module Puts Hello.welcome Hello!! Welcome |
|