title: How do I initialize object vals with values known only at runtime?
body: <p>Let's say I'm trying to write a simple Tic-Tac-Toe game. It has an M x N field. The game has only one field, so it probably should be represented with a singleton <code>object</code>. Like this:</p>
  
  <pre><code>object Field {
      val height : Int = 20
      val width : Int = 15
      ...
  }
  </code></pre>
  
  <p>But I don't want to hardcode the height and width, so it would be nice if those could be passed to the object at runtime, via a constructor or something. But <code>object</code>s cannot have constructors.</p>
  
  <p>Well, I could change <code>height</code> and <code>width</code> to be <code>var</code>s, and not <code>val</code>s and introduce a new method</p>
  
  <pre><code>def reconfigure (h:Int, w:Int) = {
      height = h
      width = w
  }
  </code></pre>
  
  <p>and call it at the begining of the game. But it's not elegant as well.</p>
  
  <p>So, is there a neat way of doing this - i.e. having object <code>val</code>s initialized with values not known before runtime?</p>