Forum: Ruby require behaviour

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A4e57ee39838ea9623272392ac4b5274?d=identicon&s=25 Maran Chandrasekar (manimaran)
on 2009-02-11 13:30
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')
42773b24e0c3fb506a8a875c058a9dd7?d=identicon&s=25 Dylan Evans (Guest)
on 2009-02-11 13:43
(Received via mailing list)
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.
42773b24e0c3fb506a8a875c058a9dd7?d=identicon&s=25 Dylan Evans (Guest)
on 2009-02-11 13:44
(Received via mailing list)
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
This topic is locked and can not be replied to.