Skip to content

Commit 5b555ca

Browse files
authored
Simplify flatten
Simplify `IterableOps#flatten` so that implementations only need to override `flatMap`
1 parent 9528bab commit 5b555ca

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

library/src/scala/collection/Iterable.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
672672

673673
def flatMap[B](f: A => IterableOnce[B]): CC[B] = iterableFactory.from(new View.FlatMap(this, f))
674674

675-
def flatten[B](implicit asIterable: A => IterableOnce[B]): CC[B] =
676-
iterableFactory.from(new View.FlatMap(this, asIterable))
675+
def flatten[B](implicit asIterable: A => IterableOnce[B]): CC[B] = flatMap(asIterable)
677676

678677
def collect[B](pf: PartialFunction[A, B]): CC[B] =
679678
iterableFactory.from(new View.Collect(this, pf))

0 commit comments

Comments
 (0)