Dan O'Brien
02/15/2022, 8:30 PM{}
block after instantiating the class?Joffrey
02/15/2022, 8:30 PMapply
for this:
val x = YourClass().apply {
prop1 = 42
prop2 = "test"
}
Dan O'Brien
02/15/2022, 8:32 PMJoffrey
02/15/2022, 8:35 PMlet
, also
, apply
, run
and with
.
They are all variations of the same thing, you have access to the instance as this
or as parameter, and it either returns the initial object or the result of the lambda.