ice spirit
ice spirit

Reputation: 1535

Type inference failed. the value of the type parameter t should be mentioned in input types

I am beginner at kotlin and I am trying to filter items which are present in one list, however i am using a loop and iterator for this purpose. I am getting mentioned exception in the if condition in here . Can some one guide me where i am wrong. I am pasting my function here .

fun getGateWays(
        gateways: ArrayList<JsonObject>?,
        callback: ResponseCallback<ArrayList<JsonObject>, String>
    ) {


        getDistinctGateways(object : ResponseCallback<List<String>?, String>() {

            override fun onFailure(failure: String) {
            }

            override fun onSuccess(response: List<String>?) {

                for(e in gateways!!.iterator()){
                    if(e.get("value") in response){
                        gateways.remove(e)
                    }
                }
                callback.onSuccess(gateways!!)
            }

        })

    }

Upvotes: 25

Views: 35809

Answers (2)

Andrei Tanana
Andrei Tanana

Reputation: 8422

You have to get a string value of each gateway in the list. You can do it with asString method of JsonObject:

if (e.get("value").asString in response!!) {
    gateways.remove(e)
}

Upvotes: 6

Kishan Maurya
Kishan Maurya

Reputation: 3394

This is because

    gateways.iterator() will give Iterator<JsonObject>
    e is of JsonObject type and response is the type List<String>

Upvotes: 2

Related Questions