val lines = input.getLines.collect ã¯2.8ã§ã¯ä½¿ããªãã import scala.io._ def toInt(in:String):Option[Int] = try { Some(Integer.parseInt(in.trim)) } catch { case e: NumberFormatException => None } def sum(in:Seq[String]) = { val ints = in.flatMap(s => toInt(s)) ints.foldLeft(0)((a, b) => a + b) } println("Enter some numbers and press ctrl-D (Unix/Mac) ctrl-Z (Windows)") val input = Source.fromInputStream(S
{{#tags}}- {{label}}
{{/tags}}