Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class CalculatorState {
var v1 by mutableStateOf("0")
var v2 by mutableStateOf("0")
val result get() = sum(v1, v2)
}
fun sum(v1: String, v2: String) = try {
(v1.toInt() + v2.toInt()).toString()
} catch (e: NumberFormatException) {
"Parsing error :("
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment