ruby - Create an array of arrays -


i'm trying create array of arrays used in javascript function.

here format of array i'm trying create:

[[1,1],[2,3],[3,6],[4,10],[5,15],[6,21]] 

here ruby code create array:

total=0 foo=[] (1..6).each |number|    foo.push [number, total+=number] end puts foo 

here output of puts foo:

1 1 2 3 3 6 4 10 5 15 6 21 

any ideas how output correctly formatted array?

if understand correctly, want output array somewhere in document interpreted javascript browser.

when comes using ruby objects in javascript, can use json gem.

require 'json' #create array foo.to_json 

should trick.

this works hashes , other object types.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -