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
is no longer supported. Instead, it is recommended to use the equivalent `while` loop
11
+
below:
12
+
```scala
13
+
while ({ <body> ; <cond> }) ()
14
+
```
15
+
For instance, instead of
16
+
```scala
17
+
do
18
+
i +=1
19
+
while (f(i) ==0)
20
+
```
21
+
one writes
22
+
```scala
23
+
while ({
24
+
i +=1
25
+
f(i) ==0
26
+
}) ()
27
+
```
28
+
Under the [new syntax rules](../other-new-features/control-syntax), this code can be written also without the awkward `({...})` bracketing like this:
29
+
```scala
30
+
while {
31
+
i +=1
32
+
f(i) ==0
33
+
} do ()
34
+
```
35
+
The idea to use a block as the condition of a while also gives a solution
36
+
to the "loop-and-a-half" problem. For instance:
37
+
```scala
38
+
while {
39
+
valx:Int= iterator.next
40
+
x >=0
41
+
} do print(".")
42
+
```
43
+
44
+
### Why Drop The Construct?
45
+
46
+
-`do-while` is used relatively rarely and it can expressed faithfully using just while. So there seems to be little point in having it as a separate syntax construct.
47
+
- Under the [new syntax rules](../other-new-features/control-syntax)`do` is used
48
+
as a statement continuation, which would clash with its meaning as a statement
0 commit comments