Skip to content

Instantly share code, notes, and snippets.

@fabioCollini
Created September 19, 2021 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabioCollini/171f34c41eae8d168cc4831d04ade31d to your computer and use it in GitHub Desktop.
Save fabioCollini/171f34c41eae8d168cc4831d04ade31d to your computer and use it in GitHub Desktop.
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