3 ms·
Are you complaining about variables being shadowed or mutable? Your complaint seems to be about the first but the examples about the second. Note that any good
by uberman 6y ago
Are you complaining about variables being shadowed or mutable? Your complaint seems to be about the first but the examples about the second.
Note that any good linter will warn you about shadowing even if it is technically allowed by the language.
- travisgriggs 6y agoI'm not sure what I'm complaining about. :) I'm still trying to form my argument I guess. I think you're correct that I'm using conflicting examples. I should have left the functional part out. And the other example is one that is only applicable in that it invokes the same sense "it's bad when you look at a variable (mutable or not) and don't really know what you're looking at, but have to reinterpret the context leading up to the use to figure out what it is". Take the following guts of a Kotlin method body I just stumbled on: upgradeStream?.bytesReceived = ubytes.copyOfRange(0, 2).le.ushort this.binding.progressBar.updateProgress(upgradeStream?.progress ?: 0.0f) val upgradeStream = this.upgradeStream ?: return if (upgradeStream.areAllBytesSent) { upgradeStream.sendEndUpgrade() } else { upgradeStream.sendNextSentence() } Depending on where I'm at in this flow of code, `upgradeStream` is a different thing.