<https://medium.com/@elye.project/mastering-kotlin...
# getting-started
m
In your chaining example
Copy code
fun makeDir(path: String) = path.let{ File(it) }.also{ it.mkdirs() }
Wouldn't apply be even better than also?
Copy code
fun makeDir(path: String) = path.let{ File(it) }.apply{ mkdirs() }
no need for it
actually, we don't even need the let
Copy code
fun makeDir(path: String) = File(path).apply { mkdirs() }
But it removes the chaining, so it's not a good example anymore.
e
Good input @matej. I agree that's not the best example. If you have a better example where
also
is best used, do share. Thanks!
m
I'll try to think of one