loading...

re: What do you think about the ternary operator? VIEW POST

FULL DISCUSSION
 

I tend to use the conditional operator mostly with one-line functions or properties. The idiomatic syntax is a lot easier in C# (my most used language) for one-line functions using the conditional operator.

New Hotness:

int Max(int a, int b) => a > b ? a : b;

Old and Busted:

int Max(int a, int b) {
    if (a > b) {
        return a;
    }
    return b;
}
code of conduct - report abuse