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 on string 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

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -