mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
26 lines
566 B
HTML
26 lines
566 B
HTML
<html>
|
|
<body>
|
|
Reports a <code>when</code> expression that can be simplified by introducing a subject argument.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
fun test(obj: Any): String {
|
|
return when {
|
|
obj is String -> "string"
|
|
obj is Int -> "int"
|
|
else -> "unknown"
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>The quick fix introduces a subject argument:</p>
|
|
<pre><code>
|
|
fun test(obj: Any): String {
|
|
return when (obj) {
|
|
is String -> "string"
|
|
is Int -> "int"
|
|
else -> "unknown"
|
|
}
|
|
}
|
|
</code></pre>
|
|
</body>
|
|
</html>
|