Skip to content

Commit c42be1d

Browse files
committed
Implemented 'cast' operator
1 parent 8068cb1 commit c42be1d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4332,6 +4332,23 @@ public BlockingObservable<T> toBlockingObservable() {
43324332
return BlockingObservable.from(this);
43334333
}
43344334

4335+
/**
4336+
* Converts the elements of an observable sequence to the specified type.
4337+
*
4338+
* @return An observable sequence that contains each element of the source
4339+
* sequence converted to the specified type.
4340+
*
4341+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211842(v=vs.103).aspx">MSDN: Observable.Cast</a>
4342+
*/
4343+
public <R> Observable<R> cast() {
4344+
return map(new Func1<T, R>() {
4345+
@SuppressWarnings("unchecked")
4346+
public R call(T t) {
4347+
return (R) t;
4348+
}
4349+
});
4350+
}
4351+
43354352
/**
43364353
* Whether a given {@link Function} is an internal implementation inside rx.* packages or not.
43374354
* <p>

0 commit comments

Comments
 (0)