title: initialise a var in scala
body: <p>I have a class where I like to initialize my var by reading a configfile, which produces intermediate objects/vals, which I would like to group and hide in a method. 
  Here is the bare minimum of the problem - I call the ctor with a param i, in reality a File to parse, and the init-method generates the String s, in reality more complicated than here, with a lot of intermediate objects being created:</p>
  
  <pre><code>class Foo (val i: Int) {
  
      var s : String;
  
      def init () {
          s = "" + i 
      }
  
      init ()
  }
  </code></pre>
  
  <p>This will produce the error: <code>class Foo needs to be abstract, since variable s is not defined</code>. In this example it is easy to solve by setting the String to "": <code>var s = "";</code>, but in reality the object is more complex than String, without an apropriate Null-implementation. </p>
  
  <p>I know, I can use an Option, which works for more complicated things than String too:</p>
  
  <pre><code>var s : Option [String] = None
  
  def init () {
      s = Some ("" + i) 
  }
  </code></pre>
  
  <p>or I can dispense with my methodcall. Using an Option will force me to write Some over and over again, without much benefit, since there is no need for a None else than to initialize it that way I thought I could. </p>
  
  <p>Is there another way to achieve my goal? </p>