If statement in value class
<p>i need to validate the parameter of my value class (below) . But i get an error </p>

<blockquote>
  <p>this statement is not allowed in value class</p>
</blockquote>

<p>at compile time , is there a way around this ? Thanks. </p>

<pre><code>case class Size(val size: Long) extends AnyVal { 
   if (size &lt; 0) throw new IllegalArgumentException; // error
   def +(s: Size): Size =Size(size + s.size)
}
</code></pre>