Why can I use to
to construct a Range
for the first argument of Future.traverse
, but not until
? See the following example Scala console interaction.
scala> Future.traverse(1 to 5)(Future.successful)
val res5: scala.concurrent.Future[IndexedSeq[Int]] = Future(<not completed>)
scala> Future.traverse(1 until 5)(Future.successful)
^
error: Cannot construct a collection of type scala.collection.immutable.AbstractSeq[Int] with elements of type Int based on a collection of type scala.collection.immutable.AbstractSeq[Int].
scala> res5
val res7: scala.concurrent.Future[IndexedSeq[Int]] = Future(Success(Vector(1, 2, 3, 4, 5)))
scala>
Note that I'm using Scala 2.13.5 for the console though Scala 2.13.2 seems to have the same behavior.
For what it's worth, I noticed that to
returns Range.Inclusive
, and until
returns Range.Exclusive
. But both extend Range
, so I'm at a loss as to what is different between these two types such that Future.traverse
can take one but not the other as the first argument.