Upto isn't bad, but id probably use inject: [1,2,3].inject ([]) {|arr, elem|
arr << arr.last + elem}
I typed this on my phone, so apologies if it's slightly off.
Upto isn't bad, but id probably use inject: [1,2,3].inject ([]) {|arr, elem|
arr << arr.last + elem}
I typed this on my phone, so apologies if it's slightly off.