score:3

Accepted answer

let's go command-by-command:

val it = iterator("(a,((a,b),1.0))")
// here we got iterator on one string

val s1 = it.next // "(a,((a,b),1.0))"
        .replace("(" , "") // "a,a,b),1.0))"
        .replace(")" , "") // "a,a,b,1.0"
        .split(",") // multiple lines in array: "a", "a","b","1.0"
        .tostring // array[string].tostring returns what you got: ljava.lang.string;@d70d7a
        .split(",") // one string (because there's no "," signs)

maybe you should run tolist before tostring, because tostring is defined in a way you expect it to be defined in this implementation of list:

val s1 = ...
        .split(",")
        .tolist
        .tostring
        ...

maybe you should look at java: split() returns [ljava.lang.string;@186d4c1], why? for clarification.

score:2

.split(",") makes array and .tostring doesn't work on array and after that you are again spliting by .split(",") which i don't think helpful.

and you can also use replaceall in place of multiple replace

scala>  val it = iterator("(a,((a,b),1.0))")         
it: iterator[string] = non-empty iterator

scala>  val s1 = it.next.replaceall("[()]" , "").split(",")
s1: array[string] = array(a, a, b, 1.0)

scala> println("s1 is "+s1(0))    
s1 is a

Related Query

More Query from same tag