modding:function:or
This is an old revision of the document!
or
See or at Xelerus
Syntax | (or exp1 [exp2 … expn]) → value/Nil | |
---|---|---|
Arguments | exp1: An expression that evaluates to Nil or something else | |
[exp2 … expn] | Additional values | |
Category | logical operator | |
Returns | The value of the first expression that does not return Nil, or Nil if there is none | |
Description | Uses lazy evaluation, which means that it stops after it finds a non-Nil argument or ends up evaluating every argument if all of them return Nil |
Example
(or 1 2 3 4 5 (setq foo 6))
Return 1. Also, foo will not be set to 6.
(or Nil (eq (setq foo "bar") "baz") "qux")
Returns “qux”. Also, foo will be set to “bar”
(errblock (error b) (setq b (or c 0)) b )
If c has not been bound anything, then this code will return the error No binding for symbol [c] ### (or c 0) ### since errors are not Nil. Beware of bad code when using errBlock, as or will simply evaluate the thrown errors as true
Return to Functions list
modding/function/or.1485389624.txt.gz · Last modified: 2017/01/26 00:13 by 0xabcdef