|
|

The boolean tyro

The Boolean Tyro

This if-statement assigns a value to boolean variable b:

if (isAtHome) {
    b=  true;
}  else {
    b=  false;
}

Can you figure out a way to do the same thing with one assignment statement?
Hint: determine what value the assignment should store in b when isAtHome is true and
when isAtHome is false.

 

Below, write the assignment statement that is equivalent to the if-statement.
Then check your answer.


Feedback

 


|
|
  
Help | Glossary
© 2002 Copyright Cornell University