The syntactical precedence of match expressions has been changed. match
is still a keyword, but it is used like an alphabetical operator. This has several consequences:
match
expressions can be chained:
xs match {
case Nil => "empty"
case _ => "nonempty"
} match {
case "empty" => 0
case "nonempty" => 1
}
(or, dropping the optional braces)
xs match
case Nil => "empty"
case _ => "nonempty"
match
case "empty" => 0
case "nonempty" => 1
match
may follow a period:
if xs.match
case Nil => false
case _ => true
then "nonempty"
else "empty"
The scrutinee of a match expression must be an InfixExpr
. Previously the scrutinee could be followed by a type ascription : T
, but this is no longer supported. So x : T match { ... }
now has to be written (x: T) match { ... }
.
The new syntax of match expressions is as follows.
InfixExpr ::= ...
| InfixExpr MatchClause
SimpleExpr ::= ...
| SimpleExpr â.â MatchClause
MatchClause ::= âmatchâ â{â CaseClauses â}â
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4