BZapper
BZapper

Reputation: 330

Combing Streams in Scala?

I'm trying to combine a few Stream[String] into one, to be processed by functions downstream, not caring about orders. What's the proper way of doing this in Scala? Collect? foldLeft?

  files.map(getContentAsStream).collect(?)

Thanks!

Upvotes: 0

Views: 43

Answers (1)

Jean Logeart
Jean Logeart

Reputation: 53809

Use reduce and the ++ function which concatenates both streams:

files.map(getContentAsStream).reduce(_ ++ _)

Upvotes: 4

Related Questions