Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
deposit = sellingPrice == 0 ? 0 : (sellingPrice - interest)
What is the above in terms of pseudo-code, I am rusty on ternary operators and operator precedence as complex as this.
If sellingPrice == 0 then deposit = 0
sellingPrice == 0
else
deposit = (sellingPrice - interest)
As per docs
Use the ?: operator instead of an if-then-else statement if it makes your code more readable;
Add a comment
deposit is assigned 0 if sellingPrice equals 0 or sellingPrice - interest if not
deposit
0
sellingPrice
sellingPrice - interest
same thing as
if(sellingPrice == 0){ deposit = 0; } else{ deposit = (sellingPrice - interest); }
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.