require behaviour

M

Maran Chandrasekar

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')
 
D

Dylan Evans

[Note: parts of this message were removed to make it a legal post.]

On Wed, Feb 11, 2009 at 10:29 PM, Maran Chandrasekar <
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.
 
D

Dylan Evans

[Note: parts of this message were removed to make it a legal post.]

On Wed, Feb 11, 2009 at 10:29 PM, Maran Chandrasekar <


Send the current item to the ogiginal require.

* Original
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top