The Cash or Credit problem

Posted by Josh K on Stack Overflow See other posts from Stack Overflow or by Josh K
Published on 2010-05-12T17:27:11Z Indexed on 2010/05/12 17:34 UTC
Read the original article Hit count: 151

Filed under:
|
|
|
|

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
}

© Stack Overflow or respective owner

Related posts about theory

Related posts about statements