从 if else 语句到三元运算符的两个变量
Two variables from if else statement to ternary operator
In JAVA, what is the best way to convert the below code to use ternary operator:
if (input > 0)
{
result1 = input;
result2 = input;
}
else
{
result1 = -1;
result2 = -1;
}
简短:
result1 = result2 = input > 0 ? input : -1;
In JAVA, what is the best way to convert the below code to use ternary operator:
if (input > 0)
{
result1 = input;
result2 = input;
}
else
{
result1 = -1;
result2 = -1;
}
简短:
result1 = result2 = input > 0 ? input : -1;