Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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';


A programmer whose output is measured by LOC...


"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.


That 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 (;


Before 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.


That's syntax sugar in the English language


> 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.


What?


> what kind of programmer would ever do this?

An enterprise developer.


Laughed too hard


... and then, after a while, started crying.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: