total=0 foo=[] (1..6).each do |number| foo.push [number, total+=number] end p foo
Standard input is empty
[[1, 1], [2, 3], [3, 6], [4, 10], [5, 15], [6, 21]]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!