[REBOL] Re: Storing a logical condition
From: SunandaDH:aol at: 13-Oct-2003 16:30
Tim:
> What do I need to do so that my answer will be:
> b evaluates to 'false'
If a is still has a value, when you come to check the condition, then all you
need is a do after the either:
a: 1
b: [a = 0]
either do b [print "b evaluates to 'true'"][print "b evaluates to 'false'"]
b evaluates to 'false'
If a no longer has a value -- maybe it's been unset or is in another context
-- then the above code won't work....
a: 1
b: [a = 0]
unset 'a
either do b [print "b evaluates to 'true'"][print "b evaluates to 'false'"]
** Script Error: a has no value
....In which case, you'll have wanted to evaluate the result and save it in b
at the earlier opportunity:
a: 1
b: a = 0
unset 'a
either b [print "b evaluates to 'true'"][print "b evaluates to 'false'"]
b evaluates to 'false'
You could of course use this last possibility even if a still has a value --
but it'll set b to the logical value at the time of the test, not the current
value of a:
a: 1
b: a = 0
a: 0
either do b [print "b evaluates to 'true'"][print "b evaluates to 'false'"]
b evaluates to 'false' ;; even though a = 0 right now
Sunanda.