Best way to represent a readline loop in Scala?

后端 未结 4 1185
悲哀的现实
悲哀的现实 2021-01-08 00:41

Coming from a C/C++ background, I\'m not very familiar with the functional style of programming so all my code tends to be very imperative, as in most cases I just can\'t se

4条回答
  •  自闭症患者
    2021-01-08 01:30

    How about this?

    val lines = Iterator.continually(reader.readLine()).takeWhile(_ != null).mkString
    

提交回复
热议问题