4 ms·
That’s a nested if statement which stops being clear. return a > b ? 1 : a < b ? -1 : 0; return a < b ? -1 : a == b ? 0 : 1; return a == b ? 0 : a < b
by Retric 8y ago
That’s a nested if statement which stops being clear.
return a > b ? 1 : a < b ? -1 : 0;
return a < b ? -1 : a == b ? 0 : 1;
return a == b ? 0 : a < b ? 1 : -1;
return a > b ? 1 : a == b ? 0 : -1;
return a != b ? a > b ? -1 : 1 : 0;
return a != b ? a < b ? 1 : -1 : 0;
Are all equally valid ways of writing that code. You can get used to a convention that makes it seem more clear, but reading it they are all equally easy to decode.