Search code examples
androidkotlin

Android Kotlin - Unexpected tokens (use ';' to separate expressions on the same line)


I found couple of answers for this but I don't understand what the hell they are talking about and what to do in my case.

This is the code:

Functions().(prefs!!.getLong("userid", 0), prefs!!.getString("notifToken", "")!!)

I get Unexpected tokens (use ';' to separate expressions on the same line) for prefs!!.getString("notifToken", "")!!

And in Functions class:

fun lastOnline(userid: Long, token: String){

    val params = RequestParams()
    params.put("userid", userid)
    params.put("token", token)

    val client = AsyncHttpClient()
    client.post("https://www.bla.com/do.php", params, object : JsonHttpResponseHandler()
    {
        override fun onSuccess(statusCode: Int, headers: Array<Header>?, response: JSONArray?)
        {

        }
        override fun onFailure(statusCode: Int, headers: Array<Header>?, e: Throwable, response: JSONArray?)
        {
            Log.d("pikabo", "error")
        }
    })
}

Please help!


Solution

  • Your code boils down to Functions().(), and that does not make a lot of sense. Functions() will create an instance of your Functions class. But then you seem to be missing a function name after the ..

    I am going to guess that you are trying to call lastOnline(), in which case you need to use that function name:

    Functions().lastOnline(prefs!!.getLong("userid", 0), prefs!!.getString("notifToken", "")!!)