Quantcast
Channel: Scratch Where It's Itching
Viewing all articles
Browse latest Browse all 73

For Each Remove

$
0
0
I found this new interesting pattern to loop over all elements of a list in our production code:
    try {        for (Object element = myList.remove(0); ; element = myList.remove(0)) {            ...        }    } catch (ArrayIndexOutOfBoundsException e) {        // It's ok    }

For those who are thinking right now about using it: PLEASE DON'T!


Viewing all articles
Browse latest Browse all 73

Trending Articles