title: Scala: Splitting a string into two integers
body: <p>This is my current code. I want to split a string into two integers and stock them into variables.</p>
  
  <pre><code>val line = "1 2"
  var a = 0
  var b = 0
  val c = line.split(" ") match { case Array(x,y) =&gt; (x.toInt, y.toInt) }
  a = c._1
  b = c._2
  </code></pre>
  
  <p>Is there any way to do something like this in Scala ? This is much more compact.</p>
  
  <pre><code>(a,b) = line.split(" ") match { case Array(x,y) =&gt; (x.toInt, y.toInt) }
  </code></pre>
  
  <p>The expression line.split(" ") match { case Array(x,y) => (x.toInt, y.toInt) } returns a tupple of integers so I thought directly linked the two integers with the variables a and b would work.</p>