|
10 | 10 | | var w = ???
|
11 | 11 | | However, it's more common to initialize a variable just once
|
12 | 12 | | with a complex expression or even a block with many statements:
|
13 |
| - | val w = if (condition) 1 else -1 |
| 13 | + | val w = if condition then /* code */ else /* other code */ |
14 | 14 | | Assignment syntax can be used if there is a corresponding setter of the form:
|
15 | 15 | | def w_=(x: Int): Unit = ???
|
16 | 16 | --------------------------------------------------------------------------------------------------------------------
|
|
26 | 26 | | var x = ???
|
27 | 27 | | However, it's more common to initialize a variable just once
|
28 | 28 | | with a complex expression or even a block with many statements:
|
29 |
| - | val x = if (condition) 1 else -1 |
| 29 | + | val x = if condition then /* code */ else /* other code */ |
30 | 30 | | Assignment syntax can be used if there is a corresponding setter of the form:
|
31 | 31 | | def x_=(x: Int): Unit = ???
|
32 | 32 | --------------------------------------------------------------------------------------------------------------------
|
33 | 33 | -- [E052] Type Error: tests/neg/i22671.explain.scala:21:4 --------------------------------------------------------------
|
34 | 34 | 21 | y = 27 // error overload renamed
|
35 | 35 | | ^^^^^^
|
36 |
| - | Assignment to method x |
| 36 | + | Assignment to method x imported as y |
37 | 37 | |--------------------------------------------------------------------------------------------------------------------
|
38 | 38 | | Explanation (enabled by `-explain`)
|
39 | 39 | |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
42 | 42 | | var x = ???
|
43 | 43 | | However, it's more common to initialize a variable just once
|
44 | 44 | | with a complex expression or even a block with many statements:
|
45 |
| - | val x = if (condition) 1 else -1 |
| 45 | + | val x = if condition then /* code */ else /* other code */ |
46 | 46 | | Assignment syntax can be used if there is a corresponding setter of the form:
|
47 | 47 | | def x_=(x: Int): Unit = ???
|
48 | 48 | --------------------------------------------------------------------------------------------------------------------
|
49 | 49 | -- [E052] Type Error: tests/neg/i22671.explain.scala:25:4 --------------------------------------------------------------
|
50 | 50 | 25 | y = 27 // error val renamed
|
51 | 51 | | ^^^^^^
|
52 |
| - | Assignment to value z |
| 52 | + | Assignment to value z imported as y |
53 | 53 | |--------------------------------------------------------------------------------------------------------------------
|
54 | 54 | | Explanation (enabled by `-explain`)
|
55 | 55 | |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
58 | 58 | | var z = ???
|
59 | 59 | | However, it's more common to initialize a variable just once
|
60 | 60 | | with a complex expression or even a block with many statements:
|
61 |
| - | val z = if (condition) 1 else -1 |
| 61 | + | val z = if condition then /* code */ else /* other code */ |
62 | 62 | | Assignment syntax can be used if there is a corresponding setter of the form:
|
63 | 63 | | def z_=(x: Int): Unit = ???
|
64 | 64 | --------------------------------------------------------------------------------------------------------------------
|
|
74 | 74 | | var x = ???
|
75 | 75 | | However, it's more common to initialize a variable just once
|
76 | 76 | | with a complex expression or even a block with many statements:
|
77 |
| - | val x = if (condition) 1 else -1 |
| 77 | + | val x = if condition then /* code */ else /* other code */ |
78 | 78 | --------------------------------------------------------------------------------------------------------------------
|
79 | 79 | -- [E052] Type Error: tests/neg/i22671.explain.scala:32:6 --------------------------------------------------------------
|
80 | 80 | 32 | t.t = t // error
|
|
88 | 88 | | var t = ???
|
89 | 89 | | However, it's more common to initialize a variable just once
|
90 | 90 | | with a complex expression or even a block with many statements:
|
91 |
| - | val t = if (condition) 1 else -1 |
| 91 | + | val t = if condition then /* code */ else /* other code */ |
92 | 92 | | Assignment syntax can be used if there is a corresponding setter of the form:
|
93 | 93 | | def t_=(x: Int): Unit = ???
|
94 | 94 | --------------------------------------------------------------------------------------------------------------------
|
0 commit comments