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
This commit is contained in:
Christian Hesse 2024-07-22 17:57:22 +02:00
parent 380b3b3137
commit 8ea7805541

View file

@ -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 ];
}