@@ -143,9 +143,9 @@ When a method is called with a fewer number of parameter lists, then this will y
143143
144144For example,
145145
146- {% tabs foldLeft_partial %}
146+ {% tabs foldLeft_partial class=tabs-scala-version %}
147147
148- {% tab 'Scala 2 and 3 ' for=foldLeft_partial %}
148+ {% tab 'Scala 2' for=foldLeft_partial %}
149149``` scala mdoc:nest
150150val numbers = List (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 )
151151val numberFunc = numbers.foldLeft(List [Int ]()) _
@@ -158,6 +158,19 @@ println(cubes) // List(1, 8, 27, 64, 125, 216, 343, 512, 729, 1000)
158158```
159159{% endtab %}
160160
161+ {% tab 'Scala 3' for=foldLeft_partial %}
162+ ``` scala mdoc:nest
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+
161174{% endtabs %}
162175
163176### Comparison with "currying"
0 commit comments