``` myObj?.let { myOtherObj.property = it } ``` `...
# announcements
a
Copy code
myObj?.let { myOtherObj.property = it }
Copy code
myObj?.let(myOtherObj.property::set)
I was wondering. I just want to set a variable to other object property if my variable is not null. So, could a do something like above
.let(myOtherObj.property::set)
?
h
Using
let
the closest syntax would be:
myObj?.let { (myOtherObj::set)(it) }
Which I wouldn't suggest using, just pointing out the syntax
a
@hudsonb thanks!