Skip to content

Feature request: switch expression #343

@Apis035

Description

@Apis035

For example, if I could write this code:

rateText String

switch rate {
    case 1 rateText = "Weak"
    case 2 rateText = "Moderate"
    case 3 rateText = "Strong"
    case 4 rateText = "Powerful"
    default rateText = "Unknown"
}

Into this:

rateText String = switch rate {
    case 1 "Weak"
    case 2 "Moderate"
    case 3 "Strong"
    case 4 "Powerful"
    default "Unknown"
}

It would make the code shorter to type as rateText is only typed once. Its also much nicer to look at.

Currently, typing this switch expression makes the compiler error "unexpected switch token in expression".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions