SodiumFRP / sodium

Sodium - Functional Reactive Programming (FRP) Library for multiple languages
http://sodium.nz/
Other
851 stars 140 forks source link

typo in method ```Stream<A> orElse(Iterable<Stream<A>> ss)```? #112

Closed clinuxrulz closed 7 years ago

clinuxrulz commented 7 years ago

In the Java version I suspect that:

    public static <A> Stream<A> orElse(Iterable<Stream<A>> ss) {
        return Stream.<A>merge(ss, new Lambda2<A,A,A>() {
            public A apply(A left, A right) { return right; }
        });
    }

in Stream.java, Should be:

    public static <A> Stream<A> orElse(Iterable<Stream<A>> ss) {
        return Stream.<A>merge(ss, new Lambda2<A,A,A>() {
            public A apply(A left, A right) { return left; }
        });
    }

(swap return right; with return left;)

jam40jeff commented 7 years ago

Yes, that is correct. It looks like a bug. I checked the C# code and it does in fact return left.

jam40jeff commented 7 years ago

Actually, I just took a look at the Java code, and it is correct. Are you sure you have updated to the latest version?

jam40jeff commented 7 years ago

Sorry for the confusion, I was looking at the wrong method in the Java code. The one that operates on a collection of streams is in fact incorrect. I will fix it.

the-real-blackh commented 7 years ago

@clinuxrulz thank you for finding and reporting this! @jam40jeff thank you for fixing. This is important so I'll make a new release soon.