May 25, 2024
Yes, this. Using let for values you don't want to consume is actually dangerous.
nullableValue?.let {
doSomething()
} ?: run {
doSomethingElse()
}
If doSomething() happens to return null, then this function will break in that it'll run both blocks, not the expected design. Perhaps not very likely in practice but best avoided.