K
K
kiddle2017-11-21 16:56:01
Android
kiddle, 2017-11-21 16:56:01

How to pass arguments to a kotlin function?

Hello, maybe I'm misunderstanding something, but how to pass an argument to a function. The matter is that when I receive the data in userData it is possible to treat this variable as with JSON object. But if you pass populateTaskList to the function, then nothing works anymore.
What could be the problem?

fun getTask(token: String) {
        Fuel.get(url).responseString { request, response, result ->
            when(result) {
                is Result.Failure -> {
                    Log.d("myLogs", "oops! Didn't get effort(((")
                }
                is Result.Success -> {
                    val (data, error) = result
                    val userData = JSONObject(data).getJSONArray("data")
                    populateTaskList(userData)
                }
            }
        }
    }

    fun populateTaskList(userData: Any) {

    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Yudakov, 2017-11-21
@kiddle

The JSONArray argument type must be specified instead of Any.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question