You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scan Operator, with and without initial value behave wildly different. Intended? #286
The first value is always passed through as the first onNext. If no initial value is given, then the first source onNext is passed through and then fed as the initial value along with the next onNext.
So for this one:
source.scan(0, accumulator);
We see 0 come through first and then be accumulated with 1 and 2:
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the result of each of these iterations.
Reacted by Stu Stirling, Caique Oliveira, Eugene Brusov and JuliusDzi
Activity
benjchristensen commentedon Sep 7, 2013
The first value is always passed through as the first
onNext. If no initial value is given, then the first sourceonNextis passed through and then fed as the initial value along with the nextonNext.So for this one:
We see
0come through first and then be accumulated with1and2:In this one:
it's now actually only passing in 2 values (1 and 2) instead of 0 as initial then 1 and 2, so we get:
The first value is still passed directly through and then the next accumulated.
If I change the Observable to emit 0, 1, 2 it looks the same as when setting initialValue to 0.
... now emits this:
Javadocs: http://netflix.github.io/RxJava/javadoc/rx/Observable.html#scan(rx.util.functions.Func2)
Change endpoint names to ensure compatibility with future SB releases (…