IntelliJ IDEA Tips & Tricks #42: Transform loops with context actions

Опубликовано: 28 Сентябрь 2024
на канале: CodeOpsTech
858
2

With a live template, you can generate for loops - 'fori' for indexed for loop and 'foreach' for iterating over collections.

And you can transform an indexed for loop to forEach and forEachOrdered loops. Further, you can reverse the loop, convert to while, and then to do while, change condition checks, remove parenthesis etc.

All this with context actions - invoke it with Alt + Enter and you can do all this magic!