Inspectopedia
 
2024.3

Manually incremented index variable can be replaced with use of 'withIndex()'

Info
New
Last modified: 03 December 2024

Reports for loops with a manually incremented index variable.

for loops with a manually incremented index variable can be simplified with the withIndex() function.

Use withIndex() instead of manual index increment quick-fix can be used to amend the code automatically.

Example:

After the quick-fix is applied: