title: Reading Multiple Inputs from the Same Line the Scala Way
body: <p>I tried to use <code>readInt()</code> to read two integers from the same line but that is not how it works.</p>
  
  <pre><code>val x = readInt()
  val y = readInt()
  </code></pre>
  
  <p>With an input of <code>1 727</code> I get the following exception at runtime:</p>
  
  <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "1 727"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:492)
      at java.lang.Integer.parseInt(Integer.java:527)
      at scala.collection.immutable.StringLike$class.toInt(StringLike.scala:231)
      at scala.collection.immutable.StringOps.toInt(StringOps.scala:31)
      at scala.Console$.readInt(Console.scala:356)
      at scala.Predef$.readInt(Predef.scala:201)
      at Main$$anonfun$main$1.apply$mcVI$sp(Main.scala:11)
      at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:75)
      at Main$.main(Main.scala:10)
      at Main.main(Main.scala)
  </code></pre>
  
  <p>I got the program to work by using <code>readf</code> but it seems pretty awkward and ugly to me:</p>
  
  <pre><code>  val (x,y) = readf2("{0,number} {1,number}")
    val a = x.asInstanceOf[Int]
    val b = y.asInstanceOf[Int]
    println(function(a,b))
  </code></pre>
  
  <p>Someone suggested that I just use Java's Scanner class, (<code>Scanner.nextInt()</code>) but is there a nice idiomatic way to do it in Scala?</p>
  
  <p><em>Edit</em>: 
  My solution following paradigmatic's example:</p>
  
  <pre><code>val Array(a,b) = readLine().split(" ").map(_.toInt)
  </code></pre>
  
  <p>Followup Question: If there were a mix of types in the String how would you extract it? (Say a word, an int and a percentage as a Double)</p>