You can do this:

def repeat *arg
  arg[0]
end

Regards,
Krishna Aradhi.



On Thu, Jun 14, 2012 at 2:32 PM, Michael Sung <lists / ruby-forum.com> wrote:

> Hi,
>
> Sorry for the newbie question but how can I make a method which takes
> only an array as an argument and returns the same array as the output?
>
> For example, I tried:
>
> def repeat *arg
>  repeated = *arg
>  p repeated
> end
>
> repeat [10, 2, 2, 54]
>
>
> However, this returns: [[10, 2, 2, 54]]
>
> when I would really just like the same array repeated back: [10, 2, 2,
> 54]
>
> Thank you.
>
> --
> Posted via http://www.ruby-forum.com/.
>
>