Scala: how to traverse stream/iterator collecting results into several different collections
- 阅读更多 关于 Scala: how to traverse stream/iterator collecting results into several different collections
问题 I'm going through log file that is too big to fit into memory and collecting 2 type of expressions, what is better functional alternative to my iterative snippet below? def streamData(file: File, errorPat: Regex, loginPat: Regex): List[(String, String)]={ val lines : Iterator[String] = io.Source.fromFile(file).getLines() val logins: mutable.Map[String, String] = new mutable.HashMap[String, String]() val errors: mutable.ListBuffer[(String, String)] = mutable.ListBuffer.empty for (line <- lines