Skip to content

Commit 3e6fc1b

Browse files
committed
Apply Matt's suggestions
1 parent 1790303 commit 3e6fc1b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

content/existential-containers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ That way, one can simply write `xs.maxByOption(_.area)` in the above example, re
126126

127127
```scala
128128
// Version with subtyping:
129-
trait Polygon:
129+
trait Polygon1:
130130
def area: Double
131-
def largest1(xs: Seq[Polygon]): Option[Polygon] =
132-
xs.maxByOption(_.value.area)
131+
def largest1(xs: Seq[Polygon1]): Option[Polygon1] =
132+
xs.maxByOption(_.area)
133133

134134
// Version with existential containers:
135-
trait Polygon extends TypeClass:
135+
trait Polygon2 extends TypeClass:
136136
extension (self: Self) def area: Double
137-
def largest2(xs: Seq[Containing[Polygon]]): Option[Containing[Polygon]] =
137+
def largest2(xs: Seq[Containing[Polygon2]]): Option[Containing[Polygon2]] =
138138
xs.maxByOption(_.area)
139139
```
140140

@@ -168,7 +168,7 @@ For instance, `largest` can be written as follows in Swift:
168168

169169
```swift
170170
func largest(_ xs: [any Polygon]) -> (any Polygon)? {
171-
xs.min { (a, b) in a.area < b.area }
171+
xs.max { (a, b) in a.area < b.area }
172172
}
173173
```
174174

0 commit comments

Comments
 (0)