Find if (x != null) x else default patterns
Proprietaryif (x != null) x else default is the elvis operator written long-hand: x ?: default. The elvis form composes naturally with chains (a ?: b ?: c) and keeps the value derivation in a single expression.
org. openrewrite. kotlin. functional. FindUseElvisForNullableDefault$KtRecipemod run . --recipe= 'org. openrewrite. kotlin. functional. FindUseElvisForNullableDefault$KtRecipe'Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.