June 2018
Intermediate to advanced
310 pages
6h 32m
English
Unlike the other four scoping functions, with() is not an extension function.
This means you cannot do the following:
"scope".with { ... }
Instead, with() receives the object you want to scope as an argument:
with("scope") { println(this.length) // "this" set to the argument of with()}
And as usual, we can omit this:
with("scope") { length}
Just like run() and let(), you can return any result from with().
Read now
Unlock full access