From: Gavin Sinclair Date: 2012-02-01T20:57:55+09:00 Subject: Re: Multiple assignment in conditional On Wed, Feb 1, 2012 at 9:16 AM, Robert Klemme wrote: > Yeah, I'd agree.  But why write such obfuscated code? Here's the code with the thing that doesn't work. Of course you don't know the context, but I hope this is enlightening. # week_and_day(date) -> [17,1] week 17, day 1 (Mon) # Returns nil if the given date is not in this term. def week_and_day(date) if not self.include? date return nil elsif (week, day = @t1.week_and_day(date)) return [week, day] elsif (week, day = @t2.week_and_day(date)) week += @t1.number_of_weeks return [week, day] end end I don't see anything obfuscated about that. @t1.week_and_day(date) will return nil if the date is outside the range of @t1, so we will go to the next part of the conditional. Here it is in acceptable Ruby. # week_and_day(date) -> [17,1] week 17, day 1 (Mon) # Returns nil if the given date is not in this term. def week_and_day(date) if not self.include? date return nil elsif (week_and_day = @t1.week_and_day(date)) return week_and_day elsif (week_and_day = @t2.week_and_day(date)) week, day = week_and_day week += @t1.number_of_weeks return [week, day] end end This one has a clumsy variable name "week_and_day" and an extra line to unpack it into "week" and "day". I'm not crying mercy over one extra line, but I definitely prefer the first version. It seems more intentional. Gavin