diff --git a/_tour/multiple-parameter-lists.md b/_tour/multiple-parameter-lists.md index 632a5ab4f..324795b6c 100644 --- a/_tour/multiple-parameter-lists.md +++ b/_tour/multiple-parameter-lists.md @@ -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]()) _ @@ -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"