jeudi 22 septembre 2016

Ruby Array Elements Merging

just wondering if there're other alternatives to merging elements in an array from

[ ["time","Oct-1-2016"], ["message","test message"], ["host","localhost"] ]

to

["time=Oct-1-2016","message=test message","host=localhost"]

I've got it nailed down toarray.map {|k,v| "#{k}=#{v}"} and just wondering if there are any other ways of achieving the above without using the map function? Thanks yo!

Aucun commentaire:

Enregistrer un commentaire