Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions _tour/multiple-parameter-lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ When a method is called with a fewer number of parameter lists, then this will y

For example,

{% tabs foldLeft_partial %}
{% tabs foldLeft_partial class=tabs-scala-version %}

{% tab 'Scala 2 and 3' for=foldLeft_partial %}
{% tab 'Scala 2' for=foldLeft_partial %}
```scala mdoc:nest
val numbers = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val numberFunc = numbers.foldLeft(List[Int]()) _
Expand All @@ -158,6 +158,19 @@ println(cubes) // List(1, 8, 27, 64, 125, 216, 343, 512, 729, 1000)
```
{% endtab %}

{% tab 'Scala 3' for=foldLeft_partial %}
```scala
val numbers = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val numberFunc = numbers.foldLeft(List[Int]())

val squares = numberFunc((xs, x) => xs :+ x*x)
println(squares) // List(1, 4, 9, 16, 25, 36, 49, 64, 81, 100)

val cubes = numberFunc((xs, x) => xs :+ x*x*x)
println(cubes) // List(1, 8, 27, 64, 125, 216, 343, 512, 729, 1000)
```
{% endtab %}

{% endtabs %}

### Comparison with "currying"
Expand Down