Netflix/RxJava — pull request #390 by zsxwing (2013-09-18 05:18:48+00:00)
Title: Implemented the 'elementAt' and 'elementAtOrDefault' operators. see #41

Hi,

This implements the `ElementAt` and `ElementAtOrDefault` operators from #41.

For `ElementAt`, if the index is less than 0, or greater than or equal to the number of elements in the source sequence, an IndexOutOfBoundsException will be threw.

For `ElementAtOrDefault`, if the index is less than 0, an IndexOutOfBoundsException will be threw. What's more, I added a `defaultValue` parameter. I can not get the element type in the source observable due to type erasure. So I can not determine the default value automatically. That's why `ElementAtOrDefault` needs a `defaultValue` parameter. Here is the signature:

public static OnSubscribeFunc elementAtOrDefault(Observable source, int index, T defaultValue)