From: Yukihiro Matsumoto Date: 2005-12-10T11:29:52+09:00 Subject: Re: next, retry, break? Hi, In message "Re: next, retry, break?" on Sat, 10 Dec 2005 05:59:29 +0900, mental@rydia.net writes: |Okay, I've got a question. | |What's the correct way to implement a custom Enumerable#each which |handles next, retry and break correctly? Just do it normally. You don't have to do nothing for them. |For example: | | def each | while @current_grob | yield @current_grob.create | @current_grob = @current_grob.next_grob | end | end | |How do I make next, retry, and break work as expected? If you want "redo" to work, you have to initialize your @current_grob at the beginning of the iterating method. Since many expect "each" to enumerate all the values in the collection, initializing at the top is a good thing in general. matz.