orangy
listOf(1, “2”, 3).filterIsInstance<String>().first()
which gives you String
valuedawidhyzy
02/08/2017, 11:34 AMorangy
dawidhyzy
02/08/2017, 11:36 AMbob
02/08/2017, 12:58 PMorangy
bob
02/08/2017, 5:24 PMorangy
orangy
bob
02/08/2017, 6:53 PMfilter
and map
. And than I found that Rx actually has a filter function for it as well: ofType
bob
02/08/2017, 6:54 PMfun <T,U:T> Observable<T>.filterMap( cls:Class<U> ):Observable<U> {
return filter { cls.isInstance( it ) }
.map { cls.cast( it ) }
}