The library provides a lot of useful functions for easier usage of the language and common programming tasks. We'll explore the contracts (preconditions) functions and the so-called standard functions.
Kotlin standard library functions
Contracts
In the base Kotlin package, you can find several functions that can be used for runtime checking of data. They can be used for defining preconditions in functions. If you ever coded in Java then you probably wrote a not null precondition, with checking that an argument passed to a method is not null. The following methods are available, check, checkNotNull, require, requireNotNull and error. Let’s show some examples of them.