From: Krishna Aradhi Date: 2012-06-14T18:13:52+09:00 Subject: Re: Simple method & array question --047d7b33cef02b424a04c26b1ec5 Content-Type: text/plain; charset=ISO-8859-1 You can do this: def repeat *arg arg[0] end Regards, Krishna Aradhi. On Thu, Jun 14, 2012 at 2:32 PM, Michael Sung 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/. > > --047d7b33cef02b424a04c26b1ec5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable You can do this:

def repeat *arg
=A0 ar= g[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
=A0repeated =3D *arg
=A0p 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/.


--047d7b33cef02b424a04c26b1ec5--