From 57a030995de79dcf303fa795e01a15eaf035ede4 Mon Sep 17 00:00:00 2001 From: Attila Babo Date: Fri, 18 Sep 2020 16:08:16 +0200 Subject: [PATCH 1/3] Add trait with type to foldLeft def The original example is hard to digest as it's not clear where the A type is from. --- _tour/multiple-parameter-lists.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_tour/multiple-parameter-lists.md b/_tour/multiple-parameter-lists.md index cf1546f39d..8ddc9caede 100644 --- a/_tour/multiple-parameter-lists.md +++ b/_tour/multiple-parameter-lists.md @@ -17,7 +17,11 @@ Methods may have multiple parameter lists. Here is an example, as defined on the `TraversableOnce` trait in Scala's collections API: ``` -def foldLeft[B](z: B)(op: (B, A) => B): B +trait TraversableOnce[A] { + ... + def foldLeft[B](z: B)(op: (B, A) => B): B + ... +} ``` `foldLeft` applies a two-parameter function `op` to an initial value `z` and all elements of this collection, going left to right. Shown below is an example of its usage. From 4817b1b0b816a553f95d6da3272126662d52d0f7 Mon Sep 17 00:00:00 2001 From: Attila Babo Date: Sat, 19 Sep 2020 12:12:17 +0200 Subject: [PATCH 2/3] Update _tour/multiple-parameter-lists.md Co-authored-by: Julien Richard-Foy --- _tour/multiple-parameter-lists.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tour/multiple-parameter-lists.md b/_tour/multiple-parameter-lists.md index 8ddc9caede..556337e690 100644 --- a/_tour/multiple-parameter-lists.md +++ b/_tour/multiple-parameter-lists.md @@ -14,7 +14,7 @@ Methods may have multiple parameter lists. ### Example -Here is an example, as defined on the `TraversableOnce` trait in Scala's collections API: +Here is an example, as defined on the `Iterable` trait in Scala's collections API: ``` trait TraversableOnce[A] { From bd52a6c099058a92e8fb668a562542e0c381ccbb Mon Sep 17 00:00:00 2001 From: Attila Babo Date: Sat, 19 Sep 2020 12:12:24 +0200 Subject: [PATCH 3/3] Update _tour/multiple-parameter-lists.md Co-authored-by: Julien Richard-Foy --- _tour/multiple-parameter-lists.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tour/multiple-parameter-lists.md b/_tour/multiple-parameter-lists.md index 556337e690..bf0c0007ea 100644 --- a/_tour/multiple-parameter-lists.md +++ b/_tour/multiple-parameter-lists.md @@ -17,7 +17,7 @@ Methods may have multiple parameter lists. Here is an example, as defined on the `Iterable` trait in Scala's collections API: ``` -trait TraversableOnce[A] { +trait Iterable[A] { ... def foldLeft[B](z: B)(op: (B, A) => B): B ...