Skip to content

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

Open
@emil14

Description

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

Activity

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

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions