Page 1 of 1

someList.numbered

PostPosted: Sat Feb 14, 2009 7:59 am
by Charles
I've updated Cobra to support "for k, v in ..." for any IEnumerable<of KeyValuePair<of TKey, TValue>>. This specifically impacts the .numbered extension method for lists:
class X

def main is shared
colors = ['red', 'green', 'blue']

for i, color in colors.numbered
print i, color

for i, color in colors.numbered
assert (i==0 and color=='red') _
or (i==1 and color=='green') _
or (i==2 and color=='blue')

See also: StandardLibraryExtensionMethods

Re: someList.numbered

PostPosted: Sat Feb 14, 2009 10:04 am
by jonathandavid
Thanks, this is a great addition.

Re: someList.numbered

PostPosted: Tue Feb 17, 2009 4:12 pm
by Charles
You're welcome.