• +91 9723535972
  • info@interviewmaterial.com

Ruby Interview Questions and Answers

Question - Explain Ruby module.

Answer -

Ruby module is a collection of methods and constants. A module method may be instance method or module method. They are similar to classes as they hold a collection of methods, class definitions, constants and other modules. They are defined like classes. Objects or subclasses can not be created using modules. There is no module hierarchy of inheritance.

Modules basically serve two purposes:

They act as namespace. They prevent the name clashes.
They allow the mixin facility to share functionality between classes.
Syntax:

module ModuleName  
statement1  
statement2  
...........  
end  
Module name should start with a capital letter.

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners