// Created on savesnippets.com · https://savesnippets.com/RKflBCM9C3A68l // | Function | Receiver | Returns | Use for | // |-----------|---------|--------------|----------------------------------| // | let | it | block result | null-safe scope / transformations | // | run | this | block result | compute from `this` | // | apply | this | object | configure & return same object | // | also | it | object | side effects (logging, asserts) | // | with | this | block result | non-extension form of run | fun main() { val s = " Hello " s.let { it.trim() } // → "Hello" (transform) s.run { trim() } // → "Hello" (use `this`) s.apply { /* no mutation possible — String is immutable */ } // → " Hello " (configure & return) s.also { println("about to use $it") } // → " Hello " (side effect) with(s) { trim() } // → "Hello" (use as non-extension) }