问题
I am learning kotlin. as shown in the code below, i created a object Model and an interface. the method in the interface should return
Model.Result
but when I wrap the aforementioned data type in Observable I receive the following error
No type argument expected for class observable
please let me know how fix this issue...as i tried to find some solution in google but it does not work
Object:
public object Model {
data class Result(val query: Query)
data class Query(val searchinfo: SearchInfo)
data class SearchInfo(val totalhits: Int)
}
interface:
interface WikiService {
fun method1(): Observable<Model.Result>//No type argument expected for class observable
回答1:
Can you show imports?
You have probably imported wrong Observable class. I think you are using RxJava2
so the import should be import io.reactivex.Observable
回答2:
You are using java.util.Observable
that doesn't accept any paramter.
You should import io.reactivex.Observable
that is parametrized.
来源:https://stackoverflow.com/questions/56950569/how-to-return-observable-of-type-object-from-a-method-in-the-interface