The page on if
shows how if
can be used to
do different things based on whether the number stored in a variable
has a certain value. Sometimes, we want to store whether a particular
statement is true
or false
, without using
numbers.
hasKey = false room = -> if hasKey do roomWithKey else do roomWithoutKey roomWithKey = -> menu "unlock door": -> write "the door is unlocked!" roomWithoutKey = -> menu "unlock door": -> write "you can't without the key!" do room "pick up key": -> hasKey = true do room do room