-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scan/Reduce with Seed Factory #1835
Scan/Reduce with Seed Factory #1835
Conversation
Adds overload with seed factory as per ReactiveX#1831
cc @headinthebox for review |
Merging for another release candidate to get actual testing during this next week. |
Scan/Reduce with Seed Factory
For the mutable case, I think it is better to pass a special object such that we can hide the state, and all methods can access it without passing it as a parameter. Think something along the lines of http://msdn.microsoft.com/en-us/library/ms131051.aspx |
A special object means we can't use lambdas. The point of Observable.range(0, 1000).reduce(() -> new ArrayList<Integer>(), (list, i) -> {
list.add(i);
return list;
}).forEach(System.out::println); |
Yup, it would require an anonymous inner class, but it is also what Java 8 does https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collector.html, https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html. |
I'm okay if that's an extra overload, but I wouldn't want it to be the only way. It's very awkward using an anonymous inner class when nothing else requires that. Also, we'd have to figure out for the first time where to put a new type like this that is custom to a specific operator. |
100% agree, but I think it makes sense to adopt the Java8 overload. |
We can't as we compile to Java 6. |
We had to revert this because of ambiguity. See #1884 for the change. |
Adds overload with seed factory as per #1831