Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368324

Summary: [Xtend] support index-datastructure in template foreach loop
Product: [Tools] Xtend Reporter: Moritz Eysholdt <moritz.eysholdt>
Component: CoreAssignee: Project Inbox <xtend-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: cvgaviao, florian.schwarz, knut.wannheden, sebastian.zarnekow, sv3n.lange, sven.efftinge
Version: 2.2.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Moritz Eysholdt CLA 2012-01-11 04:25:24 EST
It would be nice to have an index variable in an FOR loop.

Example:

«FOR item:list INDEX index»
  «index.index0» // a counter starting at 0
  «index.index1» // a counter starting at 1
  «index.isFirst» // true for the first item in the list
  «index.isLast» // true for the last item in the list
«ENDFOR»
Comment 1 Knut Wannheden CLA 2012-01-11 08:33:11 EST
I assume there would also be something like «index.value» to retrieve the index of the current item in the iterable.
Comment 2 Sebastian Zarnekow CLA 2012-01-11 08:35:30 EST
That would be either #getIndexZeroBased or #getIndexOneBased / #index0 / #index1
Comment 3 Knut Wannheden CLA 2012-01-11 08:49:35 EST
OK. I didn't quite understand the "a counter starting at 0" comment at first.