Reputation: 33
I'm having a problem because of lambda. It says that it has unexpected tokens but there are no helpful solutions in the debugger. I am new to programming and I have no idea what to do especially because in the tutorial I follow it's the same thing with no errors. The code and the screenshot are bellow. Thanks
when {
getButtonText == "Edit Profile" -> startActivity(
Intent(
context,
AccountSettingsActivity::class.java
)
)
getButtonText == "Follow" -> {
firebaseUser?.uid.let { it1 ->
FirebaseDatabase.getInstance().reference
.child("Follow").child(it1.toString())
.child("Following").child(profileId)
.setValue(true)
}
firebaseUser?.uid.let { it1 ->
FirebaseDatabase.getInstance().reference
.child("Follow").child(profileId)
.child("Followers").child(it1.toString())
.setValue(true)
}
}
}
getButtonText == "Following" -> {
firebaseUser?.uid.let { it1 ->
FirebaseDatabase.getInstance().reference
.child("Follow").child(it1.toString())
.child("Following").child(profileId)
.removeValue()
}
firebaseUser?.uid.let { it1 ->
FirebaseDatabase.getInstance().reference
.child("Follow").child(profileId)
.child("Followers").child(it1.toString())
.removeValue()
}
}
}
Upvotes: 1
Views: 274
Reputation: 4823
} <<<<
getButtonText == "Following" ->
The marked bracket is closing the when
block and should be removed. When using Android Studio you should be able to hit Ctrl+Alt+L to auto fix your formatting, including indentation. This will probably help you spot these kind of mistakes in the future
Upvotes: 1