From e8fbc163e8630a0c24c1821e4aef9bdd13cce5f8 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Fri, 13 Apr 2018 10:51:30 -0700 Subject: [PATCH] Add warning about cond --- content/en/functions/cond.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/en/functions/cond.md b/content/en/functions/cond.md index 16c1f105f..72a9c0a9a 100644 --- a/content/en/functions/cond.md +++ b/content/en/functions/cond.md @@ -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 %}} \ No newline at end of file