title: Scala return value from match case
body: <p>So here is my code:</p>
  
  <pre><code>val regexMeter = """^\s*(\d+,*\d+)\s*[m]\s*$""".r
  val regexCentimeter = """^\s*(\d+,*\d+)\s*cm\s*$""".r
  val regexDecimeter = """^\s*(\d+,*\d+)\s*dm\s*$""".r
  val regexMillimeter = """^\s*(\d+,*\d+)\s*mm\s*$""".r
  
  val height = scala.io.StdIn.readLine("Please insert the height of your shape:")
  height match {
    case regexMeter(value) =&gt; val newValue = value.toDouble*100
    case regexCentimeter(value) =&gt; val newValue = value.toDouble
    case regexDecimeter(value) =&gt; val newValue = value.toDouble*10
    case regexMillimeter(value) =&gt; val newValue = value.toDouble/10
    case _ =&gt; throw new IllegalArgumentException
  }
  </code></pre>
  
  <p>So the thing is my input is for example : "21m" and its fetching only the 21 and if its the regex matching with meters its assigning it to the <code>val newValue</code> and doing some stuff with it.
  But when I now want to print that value <code>newValue</code> it says that it cant find the value?
  How can I return this val outside from this match case?</p>