// default condition: string is not empty, not inclusive!
class TermLines (cond: (String => Boolean) = _ != "") extends Iterator[String] {
var s = readLine;
def hasNext = cond(s);
def next = { var r = s; s = readLine; r }
}
字符串 那就叫它
println((new TermLines).toVector.mkString("\n")) // till empty
型 或
println(new TermLines(_ != ".").toVector.mkString("\n")) // till last is dot
2条答案
按热度按时间wsxa1bj11#
事
字符串
那就叫它
型
或
型
mwkjh3gx2#
解决了!
字符串