File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
main/scala-2.12/collection/compat Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ package object compat {
4444 def fromSpecific (source : TraversableOnce [Int ]): C = fact.apply(source.toSeq: _* )
4545 }
4646
47+ implicit class StreamExtensionMethods [A ](private val stream : Stream [A ]) extends AnyVal {
48+ def lazyAppendAll (as : => TraversableOnce [A ]): Stream [A ] = stream.append(as)
49+ }
50+
4751 // This really belongs into scala.collection but there's already a package object in scala-library so we can't add to it
4852 type IterableOnce [+ X ] = TraversableOnce [X ]
4953}
Original file line number Diff line number Diff line change 1+ package collection
2+
3+ import org .junit .Test
4+
5+ import scala .collection .compat ._
6+
7+ class StreamTest {
8+
9+ @ Test
10+ def lazyAppendAll (): Unit = {
11+ val s = 1 #:: 2 #:: 3 #:: Stream .Empty
12+ s.lazyAppendAll(List (4 , 5 , 6 ))
13+ }
14+
15+ }
You can’t perform that action at this time.
0 commit comments