e.g.;
statement ? value if true : value if false
What are the differences between if-then-else and ?:
Is it better to use if-then-else or will ?: suffice in quick situations?
For example, It strikes me as easier and better in the below example, but I often find with many languages that there is hidden drawbacks and/or it is frowned upon. to things so I thought I would check.
Expand|Select|Wrap|Line Numbers
- food = (monkey ? banana : cheese)
Expand|Select|Wrap|Line Numbers
- if(monkey)
- {
- food = banana
- }
- else
- {
- food = cheese
- }
- OR
- if(monkey)
- food = banana
- else
- food = cheese