Clue icon indicating copy to clipboard operation
Clue copied to clipboard

Multi-expression matching support

Open Lyrth opened this issue 1 year ago • 4 comments

Would it be possible (and useful) to have match accept multiple expressions? Each match expression will match the corresponding case expression and evaluated as an and for each expression in a case.

local a, b = 2, 5
match a, b+1 {
  1,   a   => { print('no') }
  2,   4   => { print('neither') }
  b-1, 6   => { print('nay') }
  2,   a*3 => { print('THIS CASE will be selected') } 
}

If implemented, will probably be neater to have "passthrough" case expressions too, that technically works as a wildcard that always matches for that case expression, albeit it might be difficult to come up with a symbol (or existing keyword) for it.

Lyrth avatar Nov 29 '23 17:11 Lyrth