deposit = sellingPrice == 0 ? 0 : (sellingPrice - interest)
上面关于伪代码的内容是什么,我对三元运算符和像这样复杂的运算符优先级感到生锈。
If sellingPrice == 0
then deposit = 0
else
deposit = (sellingPrice - interest)
Use the ?: operator instead of an if-then-else statement if it makes your code more readable;
deposit
is assigned 0
if sellingPrice
equals 0
or sellingPrice - interest
if not
same thing as
if(sellingPrice == 0){
deposit = 0;
}
else{
deposit = (sellingPrice - interest);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.