[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

require behaviour

Maran Chandrasekar

2/11/2009 12:29:00 PM

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')
--
Posted via http://www.ruby-....

2 Answers

Dylan Evans

2/11/2009 12:41:00 PM

0

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

On Wed, Feb 11, 2009 at 10:29 PM, Maran Chandrasekar <
maran.asterisk@gmail.com> 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.

>
> --
> Posted via http://www.ruby-....
>
>


--
The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum

Dylan Evans

2/11/2009 12:43:00 PM

0

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

On Wed, Feb 11, 2009 at 10:42 PM, Dylan Evans <dylan.star@gmail.com> wrote:

>
>
> On Wed, Feb 11, 2009 at 10:29 PM, Maran Chandrasekar <
> maran.asterisk@gmail.com> wrote:
>
>
>> super( pack );
>
> Send the current item to the ogiginal require.
>

* Original