14

I have a Kotlin class with a secondary constructor, that is supposed to be used in a certain scenario. Now this should be properly documented from the first constructor so you can see it right away.

/**
* This is my class.
* 
* @constructor This is the primary constructor meant for Scenario A.
* If you are in Scenario B, please use [reference to secondary constructor] <- what do I put in here?
*/
class MyClass(val a: String) {

    constructor(b: Int) : this("$b abc")

}

I have not the slightest idea what to put in the square brackets that are meant for referencing members/functions, but I feel it should be possible. Would be great if somebody knows more about this

Enselic
  • 4,434
  • 2
  • 30
  • 42
Jan Gillich
  • 313
  • 2
  • 10

0 Answers0