From: Mike Stok Date: 2002-05-06T06:53:06+09:00 Subject: Re: Iterators and index In article <3CD59857.9050807@imperitek.com>, David Corbin wrote: > Please consider this fragment > > ---frag 1--- > list = ["Alpha", "Beta", "Gamma", "Delta" ] > > index=1 > list.each() { |letter| doSomething(index,letter); index = index+1 } > ---end--- > > But, what I'd like to be able to do, is this. > ---frag 2--- > list = ["Alpha", "Beta", "Gamma", "Delta" ] > > list.indexed_each() { |index,letter| doSomething(index+1,letter) } > ---end--- What about list.each_with_index { |letter, index| doSomething(index + 1, letter) } Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA