On Wed, Jun 27, 2012 at 10:23 AM, masta Blasta <[email protected]> wrote:
> end unless condition #->BOTHERS ME
> ...more code
> end #final end
>
Your instincts serve you well. The unless at the end is a surprise, a
hidden gotcha sprung on the reader at the last moment that completely
changes their understanding of the logic.
With effectively two levels of conditionals, this code is a good candidate
for a second method. In the extracted method, the extra condition can be
converted to a guard clause:
def the_method
...some code
some_other_method
end
def some_other_method
return unless condition
if
...some code
else
..some code
end
end
--
Avdi
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en