Well, it’s actually about kotlin … The thing is t...
# announcements
y
Well, it’s actually about kotlin … The thing is that you can’t just call primary constructor as follows
Copy code
class Spam(
  val a: String,
  val b: String,
  val c: String,
) {

  companion object decomposer {
    fun decompose() : List<String> {}
  }

  constructor (field: String) {
    val a,b,c = decompose(field)
    this(a,b,c)
  }
}
You have to assign an invocation operator for the companion object instead
Copy code
class Spam(
  val a: String,
  val b: String,
  val c: String,
) {
  companion object decomposer {

    fun decompose() : List<String> {}

    operator fun invoke(field: String) : Spam  {
      val a,b,c = decompose(field)
      return Spam(a,b,c)
    }
  }
}