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

Multiple case receivers in Switch works in an non-obvious way #788

Open
emil14 opened this issue Nov 27, 2024 · 1 comment
Open

Multiple case receivers in Switch works in an non-obvious way #788

emil14 opened this issue Nov 27, 2024 · 1 comment
Assignees
Labels

Comments

@emil14
Copy link
Collaborator

emil14 commented Nov 27, 2024

When using switch with multiple case receivers, it's important to understand that it works differently than in control flow languages. For example:

switch {
    ['Alice', 'Bob'] -> upper
    _ -> lower
}

Is not "if either Alice or Bob then do uppercase". It's a fan-in, which means Alice and Bob are concurrent to each other. Switch will select first value that will be sent as a case value, which is in this case random, because both values are message literals

@emil14 emil14 self-assigned this Nov 27, 2024
@emil14
Copy link
Collaborator Author

emil14 commented Dec 3, 2024

Maybe it's possible to support this by having some special data-type that represents "one of"? Unions?

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

No branches or pull requests

1 participant