mdedetrich commented on PR #2422:
URL: https://github.com/apache/pekko/pull/2422#issuecomment-3478418804
> That will not work, because `Source(Array(1))` will not compile, because
two methods match.
I just added
```scala
@varargs
@SafeVarargs
def apply[T](elements: T*): Source[T, NotUsed] = {
if (elements.isEmpty) {
empty[T]
} else if (elements.length == 1) {
single(elements.head)
} else {
Source(elements)
}
}
```
Locally to my `Source` in `scaladsl` and wrote this test
```scala
"product elements with varargs" in {
val p = Source(1, 2, 3).runWith(Sink.asPublisher(false))
val c = TestSubscriber.manualProbe[Int]()
p.subscribe(c)
val sub = c.expectSubscription()
sub.request(1)
c.expectNext(1)
sub.request(2)
c.expectNext(2)
sub.request(3)
c.expectNext(3)
c.expectComplete()
}
```
And it compiled fine
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]