@@ -143,9 +143,9 @@ When a method is called with a fewer number of parameter lists, then this will y
143
143
144
144
For example,
145
145
146
- {% tabs foldLeft_partial %}
146
+ {% tabs foldLeft_partial class=tabs-scala-version %}
147
147
148
- {% tab 'Scala 2 and 3 ' for=foldLeft_partial %}
148
+ {% tab 'Scala 2' for=foldLeft_partial %}
149
149
``` scala mdoc:nest
150
150
val numbers = List (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 )
151
151
val numberFunc = numbers.foldLeft(List [Int ]()) _
@@ -158,6 +158,19 @@ println(cubes) // List(1, 8, 27, 64, 125, 216, 343, 512, 729, 1000)
158
158
```
159
159
{% endtab %}
160
160
161
+ {% tab 'Scala 3' for=foldLeft_partial %}
162
+ ``` scala
163
+ val numbers = List (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 )
164
+ val numberFunc = numbers.foldLeft(List [Int ]())
165
+
166
+ val squares = numberFunc((xs, x) => xs :+ x* x)
167
+ println(squares) // List(1, 4, 9, 16, 25, 36, 49, 64, 81, 100)
168
+
169
+ val cubes = numberFunc((xs, x) => xs :+ x* x* x)
170
+ println(cubes) // List(1, 8, 27, 64, 125, 216, 343, 512, 729, 1000)
171
+ ```
172
+ {% endtab %}
173
+
161
174
{% endtabs %}
162
175
163
176
### Comparison with "currying"
0 commit comments