mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-13 20:14:58 +00:00
Add warning about cond
This commit is contained in:
1 parent
ae15a8831a
commit
e8fbc163e8
1 file changed
+6
@@ -24,3 +24,9 @@ Example:
|
||||
```
|
||||
|
||||
Would emit "goose" if the `$geese` array has exactly 1 item, or "geese" otherwise.
|
||||
|
||||
{{% warning %}}
|
||||
Whenever you use a `cond` function, *both* variable expressions are *always* evaluated. This means that a usage like `cond false (div 1 0) 27` will throw an error because `div 1 0` will be evaluated *even though the condition is false*.
|
||||
|
||||
In other words, the `cond` function does *not* provide [short-circuit evaluation](https://en.wikipedia.org/wiki/Short-circuit_evaluation) and does *not* work like a normal [ternary operator](https://en.wikipedia.org/wiki/%3F:) that will pass over the first expression if the condition returns `false`.
|
||||
{{% /warning %}}
|
||||
Reference in new issue
Block a user