i want to transform a code from if condition to a ternary condition,
first i’ve succeeded to transform one condition like:
int minutes=59,hours=23;
// 1) if condition
if (minutes<59)
minutes++;
else
minutes=0;
// 2) ternary condition
minutes = (minutes < 59) ? minutes+1 : 0;
Now the problem is when i’ve more than one value to edit it, like:
int minutes=59,hours=23;
// if condition
if (minutes<59)
minutes++;
else
{
minutes = 0;
if (hours<23)
hours++;
else
hours=0;
}
what do you think about the ternary condition ?
thanks 🙂
What I think about it is that you shouldn’t do it.
But if you really want to, you can write this:
But don’t.