in a constructor is it possible to say that the de...
# announcements
x
in a constructor is it possible to say that the default value for something if not defined is the result of a function?
👍 1
p
Copy code
class MyClass(val value: Int = f())

fun f() = 1
x
can it be anonymous? a lambda
p
Copy code
class MyClass(val value: Int = run { 1 + 1 })
like that?
x
yeah, thanks
surprised it didn’t like just = {}
p
just
{ }
is a lambda, for example:
Copy code
class MyClass(
    val selector: (Any) -> String = { it.toString() }
)