Kotlin: What are your favorite extension functions that you authored?

1 · Vishnu Haridas · Jan. 1, 2019, midnight
This article is also published at DEV.to here Kotlin has this nice feature called “Extension Functions” — adding new functionality to an existing class, without inheritance or writing lots of boilerplate code. Extension functions and extension properties are allowed in Kotlin. Here is an example Extension for the Float class by adding a new function called asDollars() to print that float number as a currency value: fun Float?.asDollars() = "USD%.2f".format(this ?: 0.0F) Now anywhere in code I ...