Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

feature: pattern matching #3

@kanersps

Description

@kanersps

Example:

var patternMatch = fun(x) {
  return match (x) {
    case { name, "location": "Eindhoven" }: {
      return name + " lives in Eindhoven"
    }
    case { name, location }: {
      return name + " doesn't live in Eindhoven but in " + location
    }    
    case default: {
      return "I don't know where " + x.name + " lives"
    }
  }
}

patternMatch({ "name": "Kane", "location": "Uden" }) // "Kane doesn't live in Eindhoven but in Uden"
patternMatch({ "name": "Jan", "location": "Eindhoven" }) // "Jan lives in Eindhoven"
patternMatch({ "name": "Emma" }) // "I don't know where Emma lives"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions