mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
DOCS: Update documentation for the select expression.
Talk about the default being optional and what will happen the field doesn't exist and no default is specified.
This commit is contained in:
parent
40107cefb6
commit
ecde7f4636
@ -507,10 +507,11 @@ Conditionals
|
|||||||
|
|
||||||
UCG supports a limited conditional expression called a select. A select
|
UCG supports a limited conditional expression called a select. A select
|
||||||
expression starts with the `select` keyword and is followed by a an expression
|
expression starts with the `select` keyword and is followed by a an expression
|
||||||
resolving to a string or boolean naming the field to select, an expression
|
resolving to a string or boolean naming the field to select, an optional
|
||||||
resolving to the default value, and finally a tuple literal to select the field
|
expression resolving to the default value, and finally a tuple literal to
|
||||||
from. If the field selected is not in the tuple then the default value will be
|
select the field from. If the field selected is not in the tuple then the
|
||||||
used.
|
default value will be used. If no default is specified then select will
|
||||||
|
throw a compile failure for the unhandled case.
|
||||||
|
|
||||||
```
|
```
|
||||||
let want = "baz";
|
let want = "baz";
|
||||||
@ -527,7 +528,7 @@ select "quack", "quux", {
|
|||||||
fuzz = "bang",
|
fuzz = "bang",
|
||||||
}; // result will be "quux"
|
}; // result will be "quux"
|
||||||
|
|
||||||
let ifresult = select true, NULL, {
|
let ifresult = select true, {
|
||||||
true = "true result",
|
true = "true result",
|
||||||
false = "false result",
|
false = "false result",
|
||||||
}; // result will be "true result"
|
}; // result will be "true result"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user