From: Xie Hanjian Date: 2009-02-03T02:21:18+09:00 Subject: Re: How to know the index value on the each method --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Elias Orozco [2009-02-03 02:13:32 +0900]: > Hello, >=20 > I was wondering if there is a way to access the current index value when > using the each method to iterate over an array. For example, >=20 > @pancakes.each do |pancake| @pancakes.each_with_index do |pancake, i| Jan >=20 > puts pancake > # How can I ask which is the current index value of pancake. I wish to > know in what position is the pancake object on the array without using a > local integer variable to count up. >=20 > end >=20 > Thanks, >=20 > El=EDas > --=20 > Posted via http://www.ruby-forum.com/. --=20 jan=3Dcallcc{|jan|jan};jan.call(jan) --HlL+5n6rz5pIUxbD Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iQEcBAEBAgAGBQJJhyuWAAoJEBcDvo3O83d6NmIH/iMVddc06zEFczCAGcXot1e+ q45enOSo3xB7/9nyeiJ5vbcHnmhgCZBvplbBuXGDe+u/2z0GpATK6BzEx4wYmQV9 VlgADmDoipNZ0K9pw8QLQJ1kOWwnnuRfQ/hWG6hY85nni1Zd80UCDPiNDBG2Fes2 KNITqMfSQQXnZdAigM0ci7Q0EW2bxa1szxpcLWW5nMk497Td98OzTXZ9lSaT+5mD 0eDE2mm1UBg92pkj/FBDcNaZsJu1QTXTr0ItUkdo5ylR5gQimysoAVMDxwmTsCJF Ja8Nz0/XC46FWrgym2Z53VEVN3MgFSWASe8+XQ5XEHEMOnl+5AHCTxHH0Qephcw= =gH+1 -----END PGP SIGNATURE----- --HlL+5n6rz5pIUxbD--