requireNotNullOrFail

fun <T : Any> T?.requireNotNullOrFail(lazyMessage: () -> String = { "The receiver cannot be null, but it was. ¯\\_(ツ)_/¯" }): T(source)

Asserts that the receiver is not null. If it is null, throws an AssertionError with the message provided by lazyMessage.

Return

the receiver if it is not null

Parameters

lazyMessage

the function to provide a message in case the receiver is null. Default message states "The receiver cannot be null, but it was. ¯\\(ツ)/¯"

Throws

if the receiver is null