Hi,
How can I turn and array like this this
[[1,2,3,4,5],[1,2,3,4,5]]
into this
[{:lt=>1,:ln=>1},{:lt=>2,:ln=>2},{:lt=>3,:ln=>3},{:lt=>4,:ln=>4},{:lt=>5,:ln=>5}]
Cheers
···
--
Posted via http://www.ruby-forum.com/.
Hi,
How can I turn and array like this this
[[1,2,3,4,5],[1,2,3,4,5]]
into this
[{:lt=>1,:ln=>1},{:lt=>2,:ln=>2},{:lt=>3,:ln=>3},{:lt=>4,:ln=>4},{:lt=>5,:ln=>5}]
Cheers
--
Posted via http://www.ruby-forum.com/.
You can try something like that :
a = [[1,2,3,4,5],[1,2,3,4,5]]
a.transpose.collect {|e| {:lt => e.first, :ln => e.last} }
Aurélien AMILIN
Le 07/04/2010 11:24, All4miller All4miller a écrit :
Hi,
How can I turn and array like this this
[[1,2,3,4,5],[1,2,3,4,5]]
into this
[{:lt=>1,:ln=>1},{:lt=>2,:ln=>2},{:lt=>3,:ln=>3},{:lt=>4,:ln=>4},{:lt=>5,:ln=>5}]
Cheers
thanks that worked great
--
Posted via http://www.ruby-forum.com/.