I have a List of Models (List items) that I loop over in my template :
@for(item <- items) {
// ...
}
I’d like to get the key/index position of the item in items for two reasons :
- I will show something like
Item n° @key - I’d like to show only 1/2 items (I suppose :
if (@key % 2))
How can I get the key/index if using a List and not a Map ?
Thanks for your help
You can zip the list with its indices:
Which prints: