Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to combine multiple conditional statements #185

Open
jpluscplusm opened this issue Oct 3, 2024 · 0 comments
Open

How to combine multiple conditional statements #185

jpluscplusm opened this issue Oct 3, 2024 · 0 comments
Labels
content idea Idea for a new piece of content howto For content that in the "howto" diataxis quadrant

Comments

@jpluscplusm
Copy link
Collaborator

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.

@jpluscplusm jpluscplusm added content idea Idea for a new piece of content howto For content that in the "howto" diataxis quadrant labels Oct 3, 2024
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Oct 24, 2024
This adds a Commented CUE that shows several examples of combining the
same set of if clauses.

Unification at the top-level of the evaluation is used in order to keep
the scope of the examples as general as possible, so that the reader can
more easily extract and use their lessons in both field and list
comprehensions - without having to first extract them from a
comprehension type that they're /not/ placed inside.

Closes cue-lang/docs-and-content#185.

Preview-Path: /docs/howto/combine-multiple-if-clauses/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: I899019354b0b31c66dcff8a2458812011499f384
Dispatch-Trailer: {"type":"trybot","CL":1203075,"patchset":1,"ref":"refs/changes/75/1203075/1","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Nov 21, 2024
This adds a guide that demonstrates a pair of scenarios where the &&
operator cannot be used, and where chained if clauses are necessary.

Closes cue-lang/docs-and-content#185.

Preview-Path: /docs/howto/combine-conditions-using-chained-if/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: I899019354b0b31c66dcff8a2458812011499f384
Dispatch-Trailer: {"type":"trybot","CL":1203075,"patchset":4,"ref":"refs/changes/75/1203075/4","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Nov 21, 2024
This adds a guide that demonstrates a pair of scenarios where the &&
operator cannot be used, and where chained if clauses are necessary.

Closes cue-lang/docs-and-content#185.

Preview-Path: /docs/howto/combine-conditions-using-chained-if/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: I899019354b0b31c66dcff8a2458812011499f384
Dispatch-Trailer: {"type":"trybot","CL":1203075,"patchset":5,"ref":"refs/changes/75/1203075/5","targetBranch":"master"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content idea Idea for a new piece of content howto For content that in the "howto" diataxis quadrant
Projects
Status: Backlog
Development

No branches or pull requests

1 participant