0

I'd like to print all values of a vector which has about 700 elements. By default, a relatively small number (maybe 100 or so) are printed, and then an ellipsis (...). Is there a way to print all the values?

Of course, I could go through the elements one by one, but I'm hoping to avoid that.

EDIT: I am printing stuff via println. Unless I've misunderstood something, changing maxPrintString doesn't seem to affect println output (or toString, since I suppose println must be calling toString).

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48

1 Answers1

1

If you're using scala's REPL, it will print out the value of whatever expression you type in, but if the toString of that value would be unreasonably long, it truncates it and adds ....

If you want the whole thing, you just need to explicily print it. Use println.

scala> val  list = List.fill(700)('a')
list: List[Char] = List(a, a, /*omitting some for brevity*/, a, ...

scala> println(list)
// it actually prints everything

// or you could print individual elements
scala> list foreach println
Dylan
  • 13,645
  • 3
  • 40
  • 67
  • Thanks, println works as you point out. I don't know why I didn't see that before, I thought I tried several things and couldn't make it work. Anyway thanks for putting me on the right track. – Robert Dodier Oct 21 '15 at 18:29