Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

kotlin

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!!)
            }

        })

    }
like image 498
ice spirit Avatar asked Oct 18 '19 04:10

ice spirit


2 Answers

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)
}
like image 130
Andrei Tanana Avatar answered Nov 03 '22 07:11

Andrei Tanana


This is because

    gateways.iterator() will give Iterator<JsonObject>
    e is of JsonObject type and response is the type List<String>
like image 32
Kishan Maurya Avatar answered Nov 03 '22 08:11

Kishan Maurya