title: When is code in Scala objects evaluated?
body: <p>Could someone explain to me why given the object:</p>
  
  <pre><code>object HelloWord {
    println("hello world")
    var z = 1
    z += {
      println("adding 1 to z")
      1
    }
  }
  </code></pre>
  
  <p>running the following code in the REPL gives:</p>
  
  <pre><code>import HelloWorld._
  // no output
  z
  // hello world
  // adding 1 to z
  // res0: Int = 2
  z
  // res1: Int = 2
  </code></pre>
  
  <p>To clarify, I would like an explanation of the output for each line of code entered into the REPL.</p>
  
  <p>Cheers</p>