Hi,
I have to string arrays with the same number of elements. Is it possible to create a new string array (or overwrite one of the existing ones) containing the string concatentation of the elements from both arrays at the same index.
zip() joins the two arrays to an array where each element is a two-element array of the corresponding items, in your example [["foo", "bar"], ["forest", "gump"]], and the map operation flattens the array via concatenation.
(Someone with better Ruby-fu can probably suggest a more elegant solution.)
Thanks. I suspected that and was just starting a ruby tutorial when your post came in (one new language per year:-))
Just if any one stumbles accross Magnus' solution. You have to take care that the input arrays are not null (or nil that is in ruby). Otherwise you get NoSuchMethod errors...
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.