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 write a switch that's not type-based #184

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

How to write a switch that's not type-based #184

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

jpluscplusm commented Oct 3, 2024

From https://cuelang.slack.com/archives/C012UU8B72M/p1722546097853739 and https://cuelang.slack.com/archives/CLT4FD7KP/p1723217773394319.

Other potential titles might include "How to write an if/else-if/else-if switch in CUE", but that's not great either.

#res: {
  #x: int
  [
    if #x > 5 { "big number"},
    "small number",
  ][0]
}

r1: #res & {#x: 5, _}
r2: #res & {#x: 6, _}
@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
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