From 5c9217fa6b33909eef35d81037db1d7733854b5d Mon Sep 17 00:00:00 2001 From: Eric Loots Date: Thu, 23 Jan 2020 19:22:42 +0100 Subject: [PATCH 1/4] Fix typo in extension method example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove an extraneous ‘.’ in example code --- docs/docs/reference/contextual/extension-methods.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/contextual/extension-methods.md b/docs/docs/reference/contextual/extension-methods.md index d8307ac6cb2e..642c4b18e865 100644 --- a/docs/docs/reference/contextual/extension-methods.md +++ b/docs/docs/reference/contextual/extension-methods.md @@ -11,7 +11,7 @@ Extension methods allow one to add methods to a type after the type is defined. ```scala case class Circle(x: Double, y: Double, radius: Double) -def (c: Circle).circumference: Double = c.radius * math.Pi * 2 +def (c: Circle) circumference: Double = c.radius * math.Pi * 2 ``` Like regular methods, extension methods can be invoked with infix `.`: From 2fec60c38166e752854fe7bcec50f8de410e5275 Mon Sep 17 00:00:00 2001 From: Eric Loots Date: Thu, 23 Jan 2020 20:07:47 +0100 Subject: [PATCH 2/4] Fix another typo in collective extension method example code --- docs/docs/reference/contextual/extension-methods.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/contextual/extension-methods.md b/docs/docs/reference/contextual/extension-methods.md index 642c4b18e865..f852073659a5 100644 --- a/docs/docs/reference/contextual/extension-methods.md +++ b/docs/docs/reference/contextual/extension-methods.md @@ -143,7 +143,7 @@ extension listOps on [T](xs: List[T]) { def third: T = xs.tail.tail.head } -extension on [T](xs: List[T]) with Ordering[T]) { +extension on [T](xs: List[T]) with Ordering[T] { def largest(n: Int) = xs.sorted.takeRight(n) } ``` From 54134d4dd2232ab733431341a3975ce98f784d4f Mon Sep 17 00:00:00 2001 From: Eric Loots Date: Fri, 24 Jan 2020 07:33:03 +0100 Subject: [PATCH 3/4] Fix typo in extension method example in other reference doc page Two files exist with alternative version of the extension method doc: - docs/docs/reference/contextual/extension-methods.md - docs/docs/reference/contextual/extension-methods-new.md --- docs/docs/reference/contextual/extension-methods-new.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/contextual/extension-methods-new.md b/docs/docs/reference/contextual/extension-methods-new.md index bdca8071881c..d6ad1a497dcc 100644 --- a/docs/docs/reference/contextual/extension-methods-new.md +++ b/docs/docs/reference/contextual/extension-methods-new.md @@ -8,7 +8,7 @@ Extension methods allow one to add methods to a type after the type is defined. ```scala case class Circle(x: Double, y: Double, radius: Double) -def (c: Circle).circumference: Double = c.radius * math.Pi * 2 +def (c: Circle) circumference: Double = c.radius * math.Pi * 2 ``` Like regular methods, extension methods can be invoked with infix `.`: From b797b3dc6732e28aaed3b4c72b09a5d2238b3c2d Mon Sep 17 00:00:00 2001 From: "Paolo G. Giarrusso" Date: Fri, 24 Jan 2020 10:27:53 +0100 Subject: [PATCH 4/4] Revert extension-methods-new.md --- docs/docs/reference/contextual/extension-methods-new.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/contextual/extension-methods-new.md b/docs/docs/reference/contextual/extension-methods-new.md index d6ad1a497dcc..bdca8071881c 100644 --- a/docs/docs/reference/contextual/extension-methods-new.md +++ b/docs/docs/reference/contextual/extension-methods-new.md @@ -8,7 +8,7 @@ Extension methods allow one to add methods to a type after the type is defined. ```scala case class Circle(x: Double, y: Double, radius: Double) -def (c: Circle) circumference: Double = c.radius * math.Pi * 2 +def (c: Circle).circumference: Double = c.radius * math.Pi * 2 ``` Like regular methods, extension methods can be invoked with infix `.`: