title: Scala: Is it possible to override val's in the sub-class's constructor?
body: <p>Is it possible to override <code>val</code>s or <code>def</code>s in the subclass's constructor? I want to initialize (or set) trait's members or abstract class's members in the subclass's constructor as <strong>parameters</strong>.</p>
  
  <p>The following is an example.</p>
  
  <pre>
  trait A {
    def memberDef: Int => String
    val memberVal: String
  }
  
  class B(
      override val memberDef: Int => String,
      override val memberVal: String)
    extends A {
    ...
  }
  </pre>
  
  <p>Here, <code>class B</code>'s <code>memberDef</code> overrides <code>trait A</code>'s <code>memberDef</code>, and <code>class B</code>'s <code>memberVal</code> overrides <code>trait A</code>'s <code>memberVal</code>.</p>
  
  <p>When I compiled this, there was no error. However, I want to know whether there are any bugs in this implementation, or whther there is a better implementation.</p>