Heesob Park
6/7/2008 2:15:00 PM
Hi,
2008/6/7 Jason Lillywhite <jason.lillywhite@gmail.com>:
> Thanks Eric!
> however, it appears when you capture the return value b by using the
> name of the method it comes from, you only get the last value of the
> array and not the array itself.
>
> the method 'counter' returns the array:
> 1.5 2
> 3.0 3
> 4.5 4
> 6.0 5
> 7.5 6
> 9.0 7
>
> and I want to take array 'b' which is:
> 1.5
> 3.0
> 4.5
> 6.0
> 7.5
> 9.0
>
> and do stuff with it, maybe even just print it out alone by calling the
> second method 'counter2'. My goal here is to learn how to take only one
> of the arrays from a method and use it in another.
Do you want something like this?
def counter
return ["1.5\t2","3.0\t3","4.5\t4","6.0\t5","7.5\t6","9.0\t7"]
end
def counter2
b = counter.map{|x|x.split(/\t/).first}
puts b
end
Regards,
Park Heesob