Search code examples
java-8functional-programmingvavr

Stream generator method in vavr


There's a following example in Vavr documentation:

// 1000 random numbers
for (double random : Stream.gen(Math::random).take(1000)) {
    ...
}

However, I cannot find the above method (gen) on Stream type in vavr javadoc.

These seem to be similar behariors:

        for (double nonRandom : Stream.range(1, 20)) {
            System.out.println(nonRandom);
        }

        for (double random : Stream.continually(Math::random).take(7)) {
            System.out.println(random);
        }

but is there a Stream.gen() somewhere as well?

Am I searching in the wrong places or is it an out-of-date method mentioned in the vavr user guide?


Solution

  • Yes, vavr documentation is outdated in that regard, as that method got renamed to Stream.continually(...) in pull request 1148 to align with the Scala API.