cue-lang / docs-and-content

A place to discuss, plan, and track documentation on cuelang.org
6 stars 1 forks source link

How to combine multiple conditional statements #185

Open jpluscplusm opened 1 month ago

jpluscplusm commented 1 month ago

From https://cuelang.slack.com/archives/CLT3ULF6C/p1725544343237119:

Today people at work were trying to write an if statement as if foo && bar {} instead of if foo if bar {} and I couldn't find an example in the docs that talks specifically about this.

Let's cover:

if foo
if bar if baz {
  something
}

... and also:

if x>1 if y<10 if z==99 {
  something
}

This demonstrates single-line and multi-line multiple-ifs, along with boolean primitives and inline conditions that evaluate to a boolean.