How to convert String to Long in Kotlin?

前端 未结 11 1032
旧时难觅i
旧时难觅i 2021-01-31 13:00

So, due to lack of methods like Long.valueOf(String s) I am stuck.

How to convert String to Long in Kotlin?

11条回答
  •  旧时难觅i
    2021-01-31 13:31

    Note: Answers mentioning jet.String are outdated. Here is current Kotlin (1.0):

    Any String in Kotlin already has an extension function you can call toLong(). Nothing special is needed, just use it.

    All extension functions for String are documented. You can find others for standard lib in the api reference

提交回复
热议问题