From: "Hal E. Fulton" Date: 2003-05-30T04:26:27+09:00 Subject: Re: Iteration - last detection ----- Original Message ----- From: "Orion Hunter" To: "ruby-talk ML" Sent: Thursday, May 29, 2003 2:14 PM Subject: Iteration - last detection > Is there any built in functionality for iteration that will allow me to > detect when I am on the last element? This would not be hard for an Array, > using array.length, but what about a Hash? How would I know when I am at > the last element? That's something I've been interested in. Search for "super-iterator" in the ML archives. I don't know that there's a solution in general unless you build your own solution. Actually, though, you can know the number of elements in a hash just as you can an array ('length' or 'size' as a synonym, just as for arrays). If you don't mind keeping a counter, that works fine. Hal