[英]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", "")!!
我得到
Unexpected tokens (use ';' to separate expressions on the same line)
用于prefs!!.getString("notifToken", "")!!
Unexpected tokens (use ';' to separate expressions on the same line)
prefs!!.getString("notifToken", "")!!
And in Functions class:在 Functions 类中:
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!请帮忙!
Your code boils down to Functions().()
, and that does not make a lot of sense.您的代码归结为
Functions().()
,这没有多大意义。 Functions()
will create an instance of your Functions
class. Functions()
将创建您的Functions
类的一个实例。 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:我猜你正在尝试调用
lastOnline()
,在这种情况下你需要使用该函数名称:
Functions().lastOnline(prefs!!.getLong("userid", 0), prefs!!.getString("notifToken", "")!!)
如果一切看起来都不错,但仍然出现相同的错误,请检查键入/粘贴的代码行中是否有任何隐藏字符
Just remove the excess !!
只要去掉多余的
!!
because it will never be null
with a default value passed into.因为它永远不会为
null
并传入默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.