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

Add match statement #621

Merged
merged 15 commits into from
Jan 15, 2025
Merged

Add match statement #621

merged 15 commits into from
Jan 15, 2025

Conversation

Akuli
Copy link
Owner

@Akuli Akuli commented Jan 15, 2025

Fixes #555

Example from docs:

enum Operation:
    Add
    Subtract
    Multiply
    Divide          # 7 / 3 produces 2.3333...
    FloorDivide     # 7 / 3 produces 2

def calculate(a: double, b: double, op: Operation) -> double:
    match op:
        case Operation.Add:
            return a + b
        case Operation.Subtract:
            return a - b
        case Operation.Multiply:
            return a * b
        case Operation.Divide:
            return a / b
        case Operation.FloorDivide:
            return floor(a / b)

@Akuli Akuli merged commit dd88edc into main Jan 15, 2025
35 checks passed
@Akuli Akuli deleted the match branch January 15, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No switch case/match case
1 participant