5 ms·
Please what kind of programmer would ever do this? if (weAreConnected === true) { this.setState({ isConnected: true }) } else
by franciscop 10y ago
Please what kind of programmer would ever do this?
if (weAreConnected === true) {
this.setState({
isConnected: true
})
}
else {
this.setState({
isConnected: false
})
}
That is just verbose unnecessarily:
this.setState({ isConnected: weAreConnected });
And probably not so popular, but this:
var color;
if (this.state.isConnected) {
color = 'green'
}
else {
color = 'red'
}
Would be simplified often to:
var color = this.state.isConnected ? 'green' : 'red';
- bbcbasic 10y ago> what kind of programmer would ever do this? An enterprise developer.
- franciscop 10y agoLaughed too hard
- Ensorceled 10y ago... and then, after a while, started crying.
- EdwardDiego 10y agoA programmer whose output is measured by LOC...
- strugglefun 10y ago> Please what kind of programmer would ever do this? Someone with an interesting development development history (maybe C?), with little grasp of the idioms of newer coding styles.
- andrewmcwatters 10y agoWhat?
- threepipeproblm 10y agoBefore 1900 Frege pointed out that we don't need to say, "The sea is salty is true"; we can just say "The sea is salty". A century later it still hasn't sunk in.
- bbcbasic 10y agoThat's syntax sugar in the English language
- kbart 10y ago"Please what kind of programmer would ever do this?" I've seen some coding rules/guides that explicitly forbid short form of 'if' statement usage.
- franciscop 10y agoThat statement is about the first code block; the second one as I commented is totally optional and I agree that it might not follow some code rules (;