title: How to extend an abstract class in scala and use the abstract constructor
body: <p>I have abstract class A</p>
  
  <pre><code>abstract class A{
  
  def this(obj:Object){
    this()
    obj match{
      case s:String =&gt; stringMethod(s)
      case n:Int =&gt; intMethod(n)
    }
  
    def stringMethod(s:String)
  
    def intMethod(n:Int)
  }
  </code></pre>
  
  <p>and I have a class that extends this class</p>
  
  <pre><code>class B(obj:Object) extends A(obj){
    var s:String = null
  
    def stringMethod(s:String){
      this.s = s
    }
  
    def intMethod(n:Int){
      this.s = n.toString
    }
  }
  </code></pre>
  
  <p>The point of this class is to instantiate an object and its variables depending on the class type of the object used to instantiate it but the problem is that when the abstract constructor is called, the default constructor of object which is extending the abstract object is somehow being called after. This alters the value of var s back to null. </p>
  
  <p>This a really simple implementation of my classes and I have more variables in class B and more logic inside intMethod and stringMethod. </p>
  
  <p>I realize this might be a completely wrong way of doing this, so if there is a better way please let me know.</p>