title: Scala: Call a method as part of the constructor
body: <p>I have a class in Scala with two argument for its constructor:</p>
  
  <pre><code>class SomeClass (x:Int, y:Int) {
  }
  </code></pre>
  
  <p>I need to expand the constructor so when an object of this class is initialized, some method is called, which uses the value of <code>x</code> defined in the primary constructor defaulted by Scala, and then outputs a value <code>z</code>: </p>
  
  <pre><code>def defineInputs(): Int = {
      val z = x + 1
      z
  }
  </code></pre>
  
  <p>I want the value of <code>z</code> to be accessible publicly to all methods in the class, just like <code>x</code> and <code>y</code> are.</p>
  
  <p>Can you please help me with this ?</p>