← Docs
kotlin-stdlib / kotlin / Result / getOrNull

getOrNull

Common
JVM
JS
Native
1.0
fun getOrNull ( ) : T ?
(source)

Returns the encapsulated value if this instance represents success or null if it is failure .

This function is a shorthand for getOrElse { null } (see getOrElse ) or fold(onSuccess = { it }, onFailure = { null }) (see fold ).

Stay in touch:
  • Contributing to Kotlin
  • Releases
  • Press Kit
  • Security
  • Blog
  • Issue Tracker
  • Brand assets
  • Careers
Supported and developed by JetBrains .
Kotlin™ is protected under the Kotlin Foundation
and licensed under the Apache 2 license .