Require behaviour

Dear folks,
I’m new to ruby, Please explain the following snippet’s behavior

def require( *packages )
packages.each{ | pack |
super( pack );
}
end
require(‘rubygems’,‘actionmailer’)

On Wed, Feb 11, 2009 at 10:29 PM, Maran Chandrasekar <
[email protected]> wrote:

Dear folks,
I’m new to ruby, Please explain the following snippet’s behavior

def require( *packages )

Override require with an array an variable length argument list, which
will
be an array in the function

   packages.each{ | pack |

Iterate through the list where pack is the current item.

           super( pack );

Send the current item to the ogiginal require.

   }

end
require(‘rubygems’,‘actionmailer’)

Which allows you to require more than one item at a time.
Hope this helps.

On Wed, Feb 11, 2009 at 10:42 PM, Dylan E. [email protected]
wrote:

On Wed, Feb 11, 2009 at 10:29 PM, Maran Chandrasekar <
[email protected]> wrote:

           super( pack );

Send the current item to the ogiginal require.

  • Original