aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-07-22 17:57:22 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-07-22 18:28:56 +0200
commit8ea780554164ef14e5fddc1ab8692eec455a0d0c (patch)
tree85a51ab04280becc078cdbcb092848cdba73126f
parent380b3b3137710eee28ca1a1b7362ae6d5b99c784 (diff)
global-functions: $EitherOr: pass boolean value
Note that literal "true" or "false" (even without quotes) is converted to string. So you may have to enclose it in parentheses for a boolean value: > :put [ :typeof [ $EitherOr true false ] ]; str > :put [ :typeof [ $EitherOr (true) (false) ] ]; bool
-rw-r--r--global-functions.rsc3
1 files changed, 3 insertions, 0 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index 54dcb68..4f37fa5 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -382,6 +382,9 @@
:set EitherOr do={
:global IfThenElse;
+ :if ([ :typeof $1 ] = "bool") do={
+ :return $1;
+ }
:if ([ :typeof $1 ] = "num") do={
:return [ $IfThenElse ($1 != 0) $1 $2 ];
}