Yep, companion object invoke trick is well-known: ...
# announcements
o
Yep, companion object invoke trick is well-known:
Copy code
data class Foo private constructor(val string: String, val num: Int, val riskyList: List<Int>) {
    companion object {
        operator fun invoke(string: String, num: Int, riskyList: List<Int>) = Foo(string, num, ArrayList(riskyList)) 
    }
}

fun test() {
    Foo("", 1, listOf(1))
}