Bug 368324 - [Xtend] support index-datastructure in template foreach loop
Summary: [Xtend] support index-datastructure in template foreach loop
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-11 04:25 EST by Moritz Eysholdt CLA
Modified: 2013-11-15 06:17 EST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.