From mboxrd@z Thu Jan 1 00:00:00 1970 From: wmorgan-sup@masanjin.net (William Morgan) Date: Sat, 02 Feb 2008 20:35:33 -0800 Subject: [sup-talk] [PATCH] don't try to open the next thread if there isn't one available In-Reply-To: <1201732604-sup-4815@archie> References: <1201681010-sup-3463@archie> <1201732604-sup-4815@archie> Message-ID: <1202013064-sup-8151@south> Reformatted excerpts from its.jeff.balogh's message of 2008-01-30: > The :next case guards against this exception with 'if block_given? && > yield'. If I put that in the :kill case, those two lines will be > exact duplicates of the lines above. > > Is there a clean way to handle this? I'm learning Ruby as I go along, > so please forgive me if the answer is obvious. To answer your question, depends what you mean by clean. We can capture the shared lines in a closure with lambda { ... }, or we can move them to a function and call the function, but that's basically the extent of the control flow power we have here. (Well, unless we want to start using continuations!) In the latest version of the code, the shared lines are now exactly the same, and are simply duplicated. Maybe once a :prev branch is added a refactor will be necessary. -- William