Second constructor not supported any longer?


#1

I found this from http://confluence.jetbrains.net/display/Kotlin/Classes+and+Inheritance
class C(a : Int) {
  // Secondary constructor
  this(s : String) : this(s.length) { ... }
}

But it does not work now :frowning:

Because jaxrs binding needs a constructor with no-args  ,  I have to rewrite my class as following :

  import javax.xml.bind.annotation.XmlRootElement

XmlRootElement

public class Result<T>{

  var count:Int = 0

  var pageSize:Int = 0

  var records:List<T> = arrayList<T>()

  class object {

  // for convenience

  fun new<T>(count:Int,pageSize:Int,records:List<T>):Result<T>{

           val r = Result<T>()

           r.count = count

           r.pageSize = pageSize

           r.records = records

           return r

  }

  }

}

Or there's another better way ?

Thanks.


Outersky

#2

There's no other way yet, but you can vote for this request: http://youtrack.jetbrains.com/issue/KT-2587