News for hackers. Stuff that matters.
Re:Why I'm not a React Native developer by microcolonel on Saturday August 19, 2017 @08:01PM (#15056277)
There's also the

    if isConnected {
      backgroundColor = .green
    } else {
      backgroundColor = .red
    }
bit, which should be a ternary.

I figure that a good rule is: if the feature existed in C, you should know and understand it. If that feature is convenient and doesn't sacrifice performance, then you should use it.

Then there's this blatant misuse of the arc4random API, which I'm pretty sure the manpage tells you about.

    let weAreConnected: Bool = arc4random()%10 > 4
Re:Why I'm not a React Native developer by joesb on Sunday August 20, 2017 @03:45AM (#15057395)
it depends on how you want to structure your code and give sections to code.

"if (isConnected) {} else {}" emphasizes to me that there are two branches of code which depends on `isConnected` state. It may have only one thing to do right now. But this is major branch. Future git diff will probably show that the code in the body the branch are added/removed.

Ternary expression emphasizes on modification of a single attribute.