Skip to content

match expressions #243

@lutzhamel

Description

@lutzhamel

Add match expressions a la Rust to Asteroid,

let p = (1,2).
let x = (match p
   with (x,y) if x > y do
      "GT"
   with (x,y) if x < y do
      "LT"
   with _ do
      throw Error("not a valid tuple"))
assert(x =="LT").

Since it is an expression it does not have an end keyword, the end keyword would look really weird in expressions, but therefore this expression is syntactically very ambiguous similarly to lambda functions and needs to be surrounded by parens in most cases.

Metadata

Metadata

Assignees

Labels

enhancementFeatures that are directly related to the core tenet of Asteroid

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions