Making string of 2-d array in scala -
so have following in scala:
scala> val example = "hello \tmy \nname \tis \nmaria \tlee".split("\n").map(_.split("\\s+")) example: array[array[string]] = array(array(hello, my), array(name, is), array(maria, lee))
i want take each 1-d array , make string, , make array of these strings (strings should comma separated). how do this?
scala> example.map(_.mkstring) res0: array[string] = array(hellomy, nameis, marialee)
to make strings comma separated:
scala> example.map(_.mkstring(",")) res0: array[string] = array(hello,my, name,is, maria,lee)
Comments
Post a Comment