<@U1ME5NXB8> `myRef.java.newInstance()` or `myRef....
# getting-started
k
@loloof64
myRef.java.newInstance()
or
myRef.java.constructors[0].newInstance(true)
, or the KClass way:
Copy code
val myRef: KClass<out PromotablePiece> = Queen::class
    val constructors: Collection<KFunction<PromotablePiece>> = myRef.constructors
    val first: KFunction<PromotablePiece> = constructors.first()
    val parameter = first.parameters.find { it.name == "whitePlayer" }!!
    val instance: PromotablePiece = first.callBy(mapOf(parameter to true))
👍 2