Library Helpers

Many useful functions from the Kotlin standard library such as with(), run(), apply(), let() and also() appear at first to be built-in language constructs.

with() is not the only one helper function; there are four more which are very similar. They have the same goal of performing several operations on the object in a concise way. All new functions run(), apply(), let() and also() are extension functions that take a lambda as an argument; they differ in whether it’s a lambda with receiver or a regular lambda, and in what they return. Let’s introduce them slowly one by one to prevent confusion.

End of sample. See AtomicKotlin.com for full early-access book.



Previous          Next

©2018 Mindview LLC. All Rights Reserved.