You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The _conditional expression_`if (´e_1´) ´e_2´ else ´e_3´` chooses one of the values of ´e_2´ and ´e_3´, depending on the value of ´e_1´.
@@ -700,6 +705,7 @@ The conditional expression `if (´e_1´) ´e_2´` is evaluated as if it was `if
700
705
701
706
```ebnf
702
707
Expr1 ::= ‘while’ ‘(’ Expr ‘)’ {nl} Expr
708
+
| ‘while’ Expr ‘do’ Expr
703
709
```
704
710
705
711
The _while loop expression_`while (´e_1´) ´e_2´` is typed and evaluated as if it was an application of `whileLoop (´e_1´) (´e_2´)` where the hypothetical method `whileLoop` is defined as follows.
@@ -874,15 +880,19 @@ The type of a throw expression is `scala.Nothing`.
A _try expression_ is of the form `try { ´b´ } catch ´h´` where the handler ´h´ is usually a [pattern matching anonymous function](08-pattern-matching.html#pattern-matching-anonymous-functions)
888
+
A _try expression_ is of the form `try ´b´ catch ´h´` where the handler ´h´ is usually a [pattern matching anonymous function](08-pattern-matching.html#pattern-matching-anonymous-functions)
881
889
882
890
```scala
883
891
{ case ´p_1´ => ´b_1´ ... case ´p_n´ => ´b_n´ }
884
892
```
885
893
894
+
If the handler is a single `ExprCaseClause`, it is a shorthand for that `ExprCaseClause` wrapped in a pattern matching anonymous function.
895
+
886
896
This expression is evaluated by evaluating the block ´b´.
887
897
If evaluation of ´b´ does not cause an exception to be thrown, the result of ´b´ is returned.
888
898
Otherwise the handler ´h´ is applied to the thrown exception.
@@ -891,22 +901,22 @@ If the handler contains no case matching the thrown exception, the exception is
891
901
More generally, if the handler is a `PartialFunction`, it is applied only if it is defined at the given exception.
892
902
893
903
Let ´\mathit{pt}´ be the expected type of the try expression.
894
-
The block ´b´ is expected to conform to ´\mathit{pt}´.
904
+
The expression ´b´ is expected to conform to ´\mathit{pt}´.
895
905
The handler ´h´ is expected conform to type `scala.Function[scala.Throwable, ´\mathit{pt}\,´]`.
896
906
The type of the try expression is the [least upper bound](03-types.html#least-upper-bounds-and-greatest-lower-bounds) of the type of ´b´ and the result type of ´h´.
897
907
898
-
A try expression `try { ´b´ } finally ´e´` evaluates the block ´b´.
908
+
A try expression `try ´b´ finally ´e´` evaluates the expression ´b´.
899
909
If evaluation of ´b´ does not cause an exception to be thrown, the expression ´e´ is evaluated.
900
910
If an exception is thrown during evaluation of ´e´, the evaluation of the try expression is aborted with the thrown exception.
901
911
If no exception is thrown during evaluation of ´e´, the result of ´b´ is returned as the result of the try expression.
902
912
903
913
If an exception is thrown during evaluation of ´b´, the finally block ´e´ is also evaluated.
904
914
If another exception ´e´ is thrown during evaluation of ´e´, evaluation of the try expression is aborted with the thrown exception.
905
915
If no exception is thrown during evaluation of ´e´, the original exception thrown in ´b´ is re-thrown once evaluation of ´e´ has completed.
906
-
The block ´b´ is expected to conform to the expected type of the try expression.
916
+
The expression ´b´ is expected to conform to the expected type of the try expression.
907
917
The finally expression ´e´ is expected to conform to type `Unit`.
908
918
909
-
A try expression `try { ´b´ } catch ´e_1´ finally ´e_2´` is a shorthand for `try { try { ´b´ } catch ´e_1´ } finally ´e_2´`.
919
+
A try expression `try ´b´ catch ´e_1´ finally ´e_2´` is a shorthand for `try { try ´b´ catch ´e_1´ } finally ´e_2´`.
0 commit comments