Kotlin
Range can be converted to indices or iteration
Info
New
Last modified: 03 December 2024 Reports until
and rangeTo
operators that can be replaced with Collection.indices
or iteration over collection inside for
loop.
Using syntactic sugar makes your code simpler.
The quick-fix replaces the manual range with the corresponding construction.
Example:
fun main(args: Array<String>) {
for (index in 0..args.size - 1) {
println(args[index])
}
}
After the quick-fix is applied:
fun main(args: Array<String>) {
for (element in args) {
println(element)
}
}
- 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.
ReplaceManualRangeWithIndicesCalls
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Kotlin, 243.23126-IJ |
Thanks for your feedback!
Was this page helpful?