Files
openide/plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/CanBeVal.html
Nikita Bobko 8b91f1c7c0 Kotlin plugin inspection descriptions: 'A quick-fix' -> 'The quick-fix'
Review: https://jetbrains.team/p/ij/reviews/98339

It's a concrete quick-fix

GitOrigin-RevId: 3388021f0cde4cb49f8c447361c0d8b2fd08cafd
2022-12-01 13:43:09 +00:00

24 lines
865 B
HTML

<html>
<body>
Reports local variables declared with the <code>var</code> keyword that are never modified.
<p>Kotlin encourages to declare practically immutable variables using the <code>val</code> keyword, ensuring that their value will never change.</p>
<p><b>Example:</b></p>
<pre><code>
fun example() {
var primeNumbers = listOf(1, 2, 3, 5, 7, 11, 13)
var fibonacciNumbers = listOf(1, 1, 2, 3, 5, 8, 13)
print("Same numbers: " + primeNumbers.intersect(fibonacciNumbers))
}
</code></pre>
<p>The quick-fix replaces the <code>var</code> keyword with <code>val</code>:</p>
<pre><code>
fun example() {
val primeNumbers = listOf(1, 2, 3, 5, 7, 11, 13)
val fibonacciNumbers = listOf(1, 1, 2, 3, 5, 8, 13)
print("Same numbers: " + primeNumbers.intersect(fibonacciNumbers))
}
</code></pre>
<!-- tooltip end -->
</body>
</html>