CSC/ECE 517 Fall 2011/ch4 4c dm: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==4c Chapter 6==
==4c Chapter 6==
=Regular Expressions=
=Regular Expressions=
=Modules=
Modules provide a structure to collect Ruby classes, methods, and constants into a single, separately named and defined unit. This is useful so that one can avoid clashes with existing classes, methods, and constants, and also so that you can add (mix in) the functionality of modules into your classes.
The definition of a module is very similar to a class. Also, modules and classes are closely related. The Module class is the immediate ancestor of the Class class. Just like a class, a module can contain constants, methods and classes.
In Ruby programming language , a module is defined in the following way
  module <module name>
    statement1
    statement2
    ...........
  end

Revision as of 17:50, 19 October 2011

4c Chapter 6

Regular Expressions

Modules

Modules provide a structure to collect Ruby classes, methods, and constants into a single, separately named and defined unit. This is useful so that one can avoid clashes with existing classes, methods, and constants, and also so that you can add (mix in) the functionality of modules into your classes. The definition of a module is very similar to a class. Also, modules and classes are closely related. The Module class is the immediate ancestor of the Class class. Just like a class, a module can contain constants, methods and classes.

In Ruby programming language , a module is defined in the following way

 module <module name>
   statement1
   statement2
   ...........
 end