Dan Fitzpatrick
3/26/2008 4:29:00 PM
On Mar 26, 2008, at 10:19 AM, pete wrote:
> Hi-
>
> This should be an easy one to answer...
>
> Is it possible to return an array from a function?
>
> Example (although a very bad one):
>
> def test(val1,val2)
> myarr = Array.new
> myarr = [val1,val2]
> return myarr
> end
>
> begin
> thisarr = test(val1,val2)
> end
>
Yes. Even shorter:
def test(val1,val2)
[val1,val2]
end