shayon shayon - 1 month ago 5x
Scala Question

Scala : Print List of List into a file : each nested list is a new line

Pretty New to Scala.
Trying this

val ListNew=List(List("this", "is", "it?"), List("yeah", "what", "else", "do","you","expect"))

into a File / Screen , like this:

this is it? \n
yeah what else do you expect

I did manage it with the following code

var ctr =0 ;> for(rec <-k ) {ctr=ctr+1 ;if (ctr == k.length){print(rec +"\n " );ctr =0; } else {print(rec+" ")} })

But I dont want counters : Is there a way to get a print "\n" before two foreach .I tried Iterators , could not get them right

println(" ")).mkString("\n"))