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 <[EMAIL PROTECTED]>
_______________________________________________
sup-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/sup-talk

Reply via email to