Back to Intellij Community

ReplaceRangeStartEndInclusiveWithFirstLast

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ReplaceRangeStartEndInclusiveWithFirstLast.html

2025.3-rc-2487 B
Original Source

Reports boxed Range.start and Range.endInclusive properties.

These properties can be replaced with unboxed first and last properties to avoid redundant calls.

The quick-fix replaces start and endInclusive properties with the corresponding first and last.

Example:

fun foo(range: CharRange) {
      val lastElement = range.endInclusive
  }

After the quick-fix is applied:

fun foo(range: CharRange) {
      val lastElement = range.last
  }