yuriy.yarosh
06/26/2016, 7:10 PMclass Testo(
val value: Int
) {
companion object parse {
operator fun invoke(value: Int): Testo {
return Testo(value + 1);
}
}
}
fun main(args: Array<String>) {
println(Testo(1).value)
}
So it’ll obviously print 1 and call primary constructor instead of the invoke() operator.
I think this one should be considered as a small issue.
Assigning invoke() operator for the companion object allows to build very neat factory methods.
Just wondering: should I create an YouTrack Kotlin issue for this matter ?