Phil Duby
2/1/2006 2:11:00 AM
"James Edward Gray II" <james@grayproductions.net> wrote in message
news:798D769A-AE90-4EE6-8D6D-F9A7A89C0CFE@grayproductions.net...
> On Jan 31, 2006, at 6:58 PM, ara.t.howard@noaa.gov wrote:
>
>> Array::new(42).map{String::new}
>
> That can be shortened to:
>
> >> Array.new(42) { String.new }
> => ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", ""]
>
> James Edward Gray II
>
>
Thank for these!!
I was looking for a clean (Ruby) way of creating an array of ascending
integer values, with the final value zero. IE [ 1, 2, 3, 4, 0 ]
i = 0; a = Array.new( 4 ) { i += 1 }.push 0
does what I want.
--
Phil
remove all of the (at)'s to send email