title: val and object inside a scala class?
body: <p>What is the difference between declaring a field as <code>val</code>, <code>lazy val</code> and <code>object</code> inside a scala class, as in the following snippet:</p>
  
  <pre><code>class A
  
  class B {
    val a1 = new A      { def foo = 1 }
    object a2 extends A { def foo = 1 }
    lazy val a3 = new A { def foo = 1 }
  }
  </code></pre>