https://kotlinlang.org logo
Title
o

oday

02/16/2018, 2:26 PM
for an actual block of code you use run
m

menegatti

02/16/2018, 2:27 PM
it doesn’t necessarily need to be
run
the important part is that you’re executing something on the event that the left side is null
you can achieve the same result with other stdlib functions… the up side of using
run
is that, in this scenario, the return type is
Unit
o

oday

02/16/2018, 2:29 PM
it is the most useful in this case yes
m

menegatti

02/16/2018, 2:29 PM
but
apply
would work practically the same
anyway, it doesn’t change the answer, just providing more info
o

oday

02/16/2018, 2:30 PM
Im speaking in Android context here, I am used to seeing apply in this context when they wanna do like
property.setText, propert.setOtherThing....