Netflix/RxJava — pull request #474 by benjchristensen (2013-11-07 23:27:08+00:00)
Title: BugFix: Reduce an empty observable

This fixes issue https://github.com/Netflix/RxJava/issues/423

The fix is based on this comment by @headinthebox: https://github.com/Netflix/RxJava/issues/423#issuecomment-27642532

Thank you @zsxwing for your involvement on this.

If I have mis-interpreted the results of the discussion and this is still wrong ... please correct me.

Here is the unit test asserting the behavior:

```java
/**
* A reduce should fail with an IllegalArgumentException if done on an empty Observable.
*/
@Test(expected = IllegalArgumentException.class)
public void testReduceWithEmptyObservable() {
Observable observable = Observable.range(1, 0);
observable.reduce(new Func2() {

@Override
public Integer call(Integer t1, Integer t2) {
return t1 + t2;
}

}).toBlockingObservable().forEach(new Action1() {

@Override
public void call(Integer t1) {
// do nothing ... we expect an exception instead
}
});

fail("Expected an exception to be thrown");
}
```