Assignments are not expressions, and only expressions are allowed in this context – Kotlin

  android-studio, kotlin
bindingSub.btnCoinup.setOnClickListener {
    fbFirestore?.collection("users")?.document(fbAuth?.uid.toString())?.get()?.addOnSuccessListener { document ->
        if (document != null) {
            var autoCoin = document.data?.values.toString().replace("[", "").replace("]", "").toLong()
            bindingSub.tvAutoCoin.setText("Coin: ${autoCoin += 1}")
        } else {
            bindingSub.tvAutoCoin.setText("Coin: 0")
        }
    } ?.addOnFailureListener { exception ->
        ...

I tried really hard to fix this error, but I couldn’t fix it.

Even if the code is dirty, I would appreciate it if you understand…

Source: Android Studio Questions

LEAVE A COMMENT