How to convert String to Long in Kotlin?

Five different coding ways to  convert String to Long in Kotlin
06 September 2017   8538

There are 5 different to convert String to Long in Kotlin programming language.

1. string.toLong()

Parses the string as a [Long] number and returns the result.
@throws NumberFormatException if the string is not a valid representation of a number.

2. string.toLongOrNull()

Parses the string as a [Long] number and returns the result or null if the string is not a valid representation of a number.

3. str.toLong(10)

Parses the string as a [Long] number and returns the result.
@throws NumberFormatException if the string is not a valid representation of a number.
@throws IllegalArgumentException when [radix] is not a valid radix for string to number conversion.

public inline fun String.toLong(radix: Int): Long = java.lang.Long.parseLong(this, checkRadix(radix))

4. string.toLongOrNull(10)

Parses the string as a [Long] number and returns the result or null if the string is not a valid representation of a number.
@throws IllegalArgumentException when [radix] is not a valid radix for string to number conversion.

public fun String.toLongOrNull(radix: Int): Long? {...}

5. java.lang.Long.valueOf(string)

public static Long valueOf(String s) throws NumberFormatException

 

Firefox Preview to Get Add-Ons Support

This is the new mobile browser that is based on the GeckoView engine and the Mozilla Android Components library set
06 February 2020   518

Mozilla developers have added support for add-ons to the codebase of the Firefox Preview mobile browser (Fenix), which is being developed to replace the Firefox edition for the Android platform. The new browser is based on the GeckoView engine and the Mozilla Android Components library set.

The ability to connect add-ons based on the WebExtension API is available for testing in the nightly builds of Firefox Preview. The item "Add-ons Manager" appeared in the menu, which shows the add-ons available for installation. In its current form, only uBlock Origin is present in the list of add-ons compatible with Firefox Preview. Support for other add-ons is expected later.

Get more at the official blog.