I'm trying to make a calculator in Android Studio with Kotlin and I trying to allow users to make numbers negative and positive, but I got only half of it, making number negative, but can't make it so it turns back to positive, for it I need to remove first char in string, someone knows how to do it?
var firstNumber: String = ...
if (firstNumber[0] == '-') {
firstNumber.
}
You could use substring
:
firstNumber = firstNumber.substring(1);