skip to Main Content
private fun mPerformDeletion() {
    when {
        state.mNumber2.isNotBlank() -> 
            state = state.copy(mNumber2 = state.mNumber2.dropLast(1))
    }
}

2

Answers


  1. Chosen as BEST ANSWER

    Sorry about that i forgot to mention the "var mNumber2" class as a data class. when i write it " data class " Error is solved.


  2. Your when should have a condition inside a bracket () but you are using {}.
    Also when is not required for single conditional statements, you can use iflike:

    private fun mPerformDeletion() {
        // assuming state is a `var` & is a `data` class
        if (state.mNumber2.isNotBlank()) { 
            state = state.copy(mNumber2 = state.mNumber2.dropLast(1))
        }
    }
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search