Skip to content

reduce() with a mutable initial value #1831

@tommack

Description

@tommack

In this example (https://github.com/ReactiveX/RxJava/wiki/Mathematical-and-Aggregate-Operators#reduce)

getComingSoonSequence()
    .reduce([], { theList, video ->
                  theList.add("'" + video.getTitle() + "' (" + video.getOpen() + ")");
                  return(theList);
    }).subscribe({ println("Coming Soon: " + it) });

Passing a list into the reduce method seems like it would only be valid if you could guarantee that the Observable would only be subscribed to once. Why isn't there a reduce method that takes a Supplier as its first argument?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions