I am still struggling a bit with these zipWithIndex and filter functions. I have this code statement , and added a test string to isolate from the rest of the code.
val s = "012345678901234567890123456789012345678901234567890123456789"
val l = s.zipWithIndex.filter{tuple => tuple._2 % 4 == 0}.map{_._1}.toString()
I had expected to get a string with every 5th character from the original string, which does kind-of happen. Instead what I get is:
Vector(0, 4, 8, 2, 6, 0, 4, 8, 2, 6, 0, 4, 8, 2, 6)
For some reason it seems to have spaces added, and also the word Vector
in the string. Where does that come from? It is there without the .toString()
(that was to change the type for later). And more to the point, how can I prevent it?