title: How to delay assignment of class values in Scala?
body: <p>I have a class that gets created using data <code>a</code> read from a .conf file. The class also contains a value <code>b</code> which does not come from the conf file.</p>
  
  <p>The class:</p>
  
  <pre><code>case class Configuration(a: String, b: String)
  </code></pre>
  
  <p>The sequence of calls to instantiate a Configuration looks like this:</p>
  
  <p>User -> <code>ConfigurationCompiler</code> -> <code>ConfigurationReader</code> -> <code>readConfig(): Configuration</code>
  (The user gets a Configuration object back)</p>
  
  <p>Value <code>a</code> gets read and set by the .conf file, but value <code>b</code> is specified by the user. I don't want to pass value <code>b</code> all the way down to readConfig() so it can be set on instantiation of <code>Configuration</code>.</p>
  
  <p>I have experimented with <code>Option</code>, but to me it looks ugly because you first instantiate <code>b</code> with <code>None</code>, and then set it later. Also, the tests look weird because you must test <code>Some(String)</code> instead of <code>String</code>. Option also doesn't seem like it fits here because the field is actually <em>not</em> optional, it is just set at a later time.</p>
  
  <p>The <code>Option</code> class:</p>
  
  <pre><code>case class Configuration(a: String, var b: Option[String])
  </code></pre>