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
@@ -80,6 +82,8 @@ case class State(n: Int, minValue: Int, maxValue: Int) {
80
82
}
81
83
}
82
84
```
85
+
{% endtab %}
86
+
{% endtabs %}
83
87
84
88
We will be able to move it to new syntax automatically in two steps: first by using the new control structure rewrite (`-new-syntax -rewrite`) and then the significant indentation rewrite (`-indent -rewrite`).
85
89
@@ -92,13 +96,19 @@ We will be able to move it to new syntax automatically in two steps: first by us
92
96
93
97
We can use the `-new-syntax -rewrite` options by adding them to the list of scalac options in our build tool.
94
98
99
+
{% tabs sbt-location %}
100
+
{% tab 'sbt' %}
95
101
```scala
96
-
// build.sbt
102
+
// build.sbt, for Scala 3 project
97
103
scalacOptions ++=Seq("-new-syntax", "-rewrite")
98
104
```
105
+
{% endtab %}
106
+
{% endtabs %}
99
107
100
108
After compiling the code, the result looks as follows:
@@ -117,6 +127,8 @@ case class State(n: Int, minValue: Int, maxValue: Int) {
117
127
}
118
128
}
119
129
```
130
+
{% endtab %}
131
+
{% endtabs %}
120
132
121
133
Notice that the parentheses around the `n == maxValue` disappeared, as well as the braces around the `i <- minValue to maxValue` and `j <- 0 to n` generators.
122
134
@@ -126,6 +138,8 @@ After this first rewrite, we can use the significant indentation syntax to remov
126
138
To do that we use the `-indent` option in combination with the `-rewrite` option.
0 commit comments