Redirecting to default login... Kotlin Language 1.5 Release Update – Mobility Center of Excellence Team Website
Print Friendly, PDF & Email

Android Kotlin Language 1.5 Release Update

September 2021: Article by Kelly Walker, Android Engineer / KP Mobile App / MCoE

The Kotlin programming language is used for Android development in many of our custom mobile apps such as KP Mobile and in our Mobile Development Kit (MDK) reusable libraries. Version 1.5 of the Kotlin programming language was released this year. JetBrains is now releasing a new feature release of Kotlin every 6 months. 1.5.0 was released in May, and here are a sampling of some of the new language features released since then.

“Sealed” interfaces

Interfaces can now be marked as “sealed”, just as classes can, which would restrict all implementations to be defined at compile time. This can be used by interfaces provided by library modules to prevent consuming code from creating their own implementations or extending the libraries’ implementation, and for adding additional class hierarchy restrictions for subclasses of sealed classes.

New “value classes”

Inline classes are now referred to as value classes – these are classes which wrap a single property, and will not incur any memory overhead for the wrapped class. Value classes are defined as “…immutable classes that disavow the concept of identity for their instances. Two instances of a value class with the same contents (fields) are indistinguishable for all purposes.” (See Kotlin notes).

Standard library functions

The standard library functions toUpperCase(), toLowerCase() and toTitleCase() have been deprecated and are being replaced by locale-agnostic versions : uppercase(), lowercase(), and titlecase() – the new versions use a language/country neutral locale by default. A locale can be specified as an argument if needed.

Kotlin has added stricter versions of the String?.toBoolean() extension function – toBooleanStrict() and toBooleanStrictOrNull() – which will either throw an exception or return null if the string value is neither “true” nor “false”.

Even more

Kotlin continues to provide enhancements to the standard library which allows developers to write more concise code. Before 1.5, in order to satisfy a requirement to obtain the first non-null element of a collection which meets certain criteria, a developer would either have to write their own code to manually loop through the collection searching for the first non-null element found that passed the test, or combine the mapNotNull() with the first() function, which would result in an intermediate set being created. Kotlin 1.5 now provides functions such as firstNotNullOf() and firstNotNullOfOrNull() which combine these operations.

New assertion functions have been added to the Kotlin test library, such as:

  • assertIs<T>() and assertIsNot<T>() provide type validation, and assertIs<T>() will also smart-cast the variable to T
  • assertContentEquals() will validate that two lists contain the same elements, in the same order

For more information visit the Kotlin language reference site. Or contact Kelly Walker.

Thank you

Thank you for reading this article. Please take a minute to send us your questions or feedback about this submission at Let us know if you have a mobile themed topic or suggestion for upcoming editions of the MCoE Newsletter!

Visit the MCoE newsletter archives.
View our tech news archives.

MCoE partnership – Contact us

KAISER PERMANENTE exists to provide high-quality, affordable health care services and to improve the health of our members and the communities we serve.

The MCoE (Mobility Center of Excellence) team exists to deliver complex mobile solutions through enterprise-wide engagements. We design, develop, certify, and deploy mobile apps for KP members, providers, and workforce.
Submit an MCoE intake form for access to app services, kits, and advice.
Email to subscribe to our newsletter and ask about our tech-newsletter for developer partner updates.

Leave a Reply