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

Select syntax sugar #728

Open
emil14 opened this issue Oct 4, 2024 · 1 comment
Open

Select syntax sugar #728

emil14 opened this issue Oct 4, 2024 · 1 comment
Assignees

Comments

@emil14
Copy link
Collaborator

emil14 commented Oct 4, 2024

See #724

Before (desugared)

flow GetString(a, b, c) (s string) {
    Select<string>
    ---
    :a -> select:if[0]
    :b -> select:if[1]
    :c -> select:if[2]

    'a' -> select:then[0]
    'b' -> select:then[1]
    'c' -> select:then[2]
    'd' -> select:else

    select -> :s
}

After (sugar)

def GetString(a, b, c) (s string) {
    select {
        :a: 'a'
        :b: 'b'
        :c: 'c'
        else: 'd'
    } -> :s
}
@emil14
Copy link
Collaborator Author

emil14 commented Nov 3, 2024

This is not like Go's select

Go's select answers not just "where from" but also "what" (you can ignore value from chan but it's there)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant