Reading Second Value In Line Scala -
i'd read line of input of form "x y" standard input using scala , assign y var. here's have far:
val array(_, t) = readline.split(" ").map(_.toint)
this looks pretty ugly though. tried val t = readline.split(" ").map(_.toint)(1), compiler complains when seek this. if there's cleaner solution using array, i'd appreciate help. thanks!
your solution val array(_, t) = readline.split(" ").map(_.toint) ok when string contains valid data.
if know sec token valid utilize this:
val t = line.split(" ")(1).toint scala
No comments:
Post a Comment