Quick question, is it possible to use class extens...
# announcements
j
Quick question, is it possible to use class extensions to add a secondary constructor to a class? I have about 50 Java classes which should be dataclasses, but since they're in Java, they only have a default constructor and some of them are nested 12 levels deep. Looking for something like this (simple example):
Copy code
fun PingRequest.constructor(username: String? = null, password: String? = null, ....): PingRequest {
    this.username = username
    this.password = password
    this.......
    return this
}
Which would now allow me to do
PingRequest(username="test", password="blah")
instead of
Copy code
val request = PingRequest()
request.username="test"
request.password="blah"
...
return request