Kotlin
If-Then foldable to '?:'
Info
New
Last modified: 03 December 2024 Reports if-then
expressions that can be folded into elvis (?:
) expressions.
Example:
fun maybeFoo(): String? = "foo"
var foo = maybeFoo()
val bar = if (foo == null) "hello" else foo
The quick fix converts the if-then
expression into an elvis (?:
) expression:
fun maybeFoo(): String? = "foo"
var foo = maybeFoo()
val bar = foo ?: "hello"
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
IfThenToElvis
Here you can find the description of settings available for the If-Then foldable to '?:' inspection, and the reference of their default values.
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Kotlin, 243.23126-IJ |
Thanks for your feedback!
Was this page helpful?