kevinmost
08/06/2017, 4:10 PMoshai
08/06/2017, 4:12 PMoshai
08/06/2017, 4:14 PMvoddan
08/06/2017, 4:27 PMveryLongExpression.let {println(it)}
voddan
08/06/2017, 4:27 PMlet
voddan
08/06/2017, 4:28 PM?.let
was advertised as a get-away drug for Swift people who are used to if let = .. {}
kevinmost
08/06/2017, 8:25 PMlet
is used to capture the value of the left-hand-side into a param of a lambda. It's meant to be a replacement for constructs you see everywhere like:
val storedValue = longComputation()
/* use storedValue */
that way you have scoping for that val and you don't end up with a bunch of local vals polluting your namespacekevinmost
08/06/2017, 8:25 PM?.
you can use it for null-checking