https://kotlinlang.org logo
#announcements
Title
# announcements
d

David W

05/19/2017, 10:26 AM
I like
apply
for when you are modifying properties of a class as you initialize it, eg:
Copy code
val obj = ObjWithoutConstructor().apply {
    somePropOfObj = "value1"
}
👍 1
m

myanmarking

05/19/2017, 10:57 AM
wispborne: agree with you
apply is good, for example, delegation
in which you can initialize some object, and need to return it at the end
and for builder-style objects, works great
d

David W

05/19/2017, 10:59 AM
yep. I use it exactly like the property initializer in C#
2 Views