January 2018
Intermediate to advanced
434 pages
14h 1m
English
Here's an example that shows parsing of string to Long:
fun main(args: Array<String>) { val str="123" print(str.toLong())}
When you run the preceding code, you will see this output:
123
If you don’t want to deal with the exceptions, you can use .toLongOrNull(). This method parses the string as a Long and returns the result, or null if the string is not a valid representation of a number.
Read now
Unlock full access