Skip to content

Iterator.continually(1).toIterable eagerly evaluated in Scala 2.13 #12141

Closed
scala/docs.scala-lang
#2354
@marko-asplund

Description

@marko-asplund

Iterator.continually(1).toIterable seems to be lazily evaluated in Scala 2.12, but eagerly in Scala 2.13.

reproduction steps

With 2.12 the following returns an Iterable[Int] backed by Stream

scala> Iterator.continually(1).toIterable
res0: Iterable[Int] = Stream(1, ?)

problem

With 2.13.3 the iterator seems to get evaluated eagerly:

scala> Iterator.continually(1).toIterable
                               ^
       warning: method toIterable in class IterableOnceExtensionMethods is deprecated (since 2.13.0): Use .iterator.to(Iterable)
// evaluation keeps running

the same result with the following except without the compiler warning

scala> Iterator.continually(1).to(Iterable)
// evaluation keeps running

I'd expect similar behaviour as with Scala 2.12.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions