Kotlin JS - string to number conversion? -
how string number conversion in kotlin js app. using following code , having trouble converting htmlinputelement
value double.
fun c2f(self: any) { console.log("self object: ${self} ") val celsius = document.getelementbyid("celcius")?.getattribute("value") double val fahrenheit = celsius * 1.8 + 32 console.log("fahrenheit value: ${fahrenheit} ") window.alert("celcius (${celsius}) -> fahrenheit (${fahrenheit}) ") }
- also not seeing
todouble()
function onstring
class in case of jvm app.
answering own question helpful somebody.
you can use kotlin.js top level parse functions string
<-> number
conversion.
fun parseint(s: string, radix: int = 10): int fun safeparseint(s : string) : int? fun safeparsedouble(s : string) : double?
Comments
Post a Comment