# Require behaviour

**URL:** <https://www.ruby-forum.com/t/require-behaviour/160065>\
**Category:** Ruby\
**Created:** [February 11, 2009, 1:30pm UTC](https://www.ruby-forum.com/t/require-behaviour/160065 "2009-02-11T13:30:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![manimaran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@manimaran](https://www.ruby-forum.com/u/manimaran)\
**Post date:** [February 11, 2009, 1:30pm UTC](https://www.ruby-forum.com/t/require-behaviour/160065/1 "2009-02-11T13:30:33Z")

</div>

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’)

---

<div class="post-metadata">

**Author:** ![manimaran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@manimaran](https://www.ruby-forum.com/u/manimaran)\
**Post date:** [February 11, 2009, 1:43pm UTC](https://www.ruby-forum.com/t/require-behaviour/160065/2 "2009-02-11T13:43:04Z")

</div>

On Wed, Feb 11, 2009 at 10:29 PM, Maran Chandrasekar \<  
removed\_email\_address@domain.invalid\> 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.

---

<div class="post-metadata">

**Author:** ![manimaran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@manimaran](https://www.ruby-forum.com/u/manimaran)\
**Post date:** [February 11, 2009, 1:44pm UTC](https://www.ruby-forum.com/t/require-behaviour/160065/3 "2009-02-11T13:44:50Z")

</div>

On Wed, Feb 11, 2009 at 10:42 PM, Dylan E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Wed, Feb 11, 2009 at 10:29 PM, Maran Chandrasekar \<  
> removed\_email\_address@domain.invalid\> wrote:
> 
> > ```
> > super( pack );
> > 
> > ```
> 
> Send the current item to the ogiginal require.

- Original
