Skip to content

Commit a5acd1e

Browse files
committed
Add lazyAppendAll alias to append in Stream
1 parent fcc3425 commit a5acd1e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/main/scala-2.12/collection/compat/package.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ package object compat {
4141
def fromSpecific(source: TraversableOnce[Int]): C = fact.apply(source.toSeq: _*)
4242
}
4343

44+
implicit class StreamExtensionMethods[A](private val stream: Stream[A]) extends AnyVal {
45+
def lazyAppendAll(as: => TraversableOnce[A]): Stream[A] = stream.append(as)
46+
}
47+
4448
// This really belongs into scala.collection but there's already a package object in scala-library so we can't add to it
4549
type IterableOnce[+X] = TraversableOnce[X]
4650
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}

0 commit comments

Comments
 (0)