The Cash or Credit problem
- by Josh K
If you go to a store and ask "Cash or Credit?" they might simply say "Yes." This doesn't tell you anything as you posed an OR statement. if(cash || credit)
With humans it's possible that they might respond "Both" to that question, or "Only {cash | credit}." Is there a way (or operator) to force the a statement to return the TRUE portions of a statement? For example:
boolean cash = true;
boolean credit = true;
boolean cheque = false;
if(cash || credit || cheque )
{
// In here you would have an array with cash and credit in it because both of those are true
}