On Wed, Feb 1, 2012 at 10:57 PM, Gavin Sinclair <gsinclair / gmail.com> wrote=
:

Sorry to reply to my own message, but I thought of something I should
have included.

Here is the forbidden version I would like to write.  Obviously I'm
combining assignment and conditional, which may not win plaudits as a
general rule.

> =A0def week_and_day(date)
> =A0 =A0if not self.include? date
> =A0 =A0 =A0return nil
> =A0 =A0elsif (week, day =3D @t1.week_and_day(date))
> =A0 =A0 =A0return [week, day]
> =A0 =A0elsif (week, day =3D @t2.week_and_day(date))
> =A0 =A0 =A0week +=3D @t1.number_of_weeks
> =A0 =A0 =A0return [week, day]
> =A0 =A0end
> =A0end

But consider this alternative, where I separate the assignment and the
conditional.

  def week_and_day(date)
    if not self.include? date
      return nil
    else
      week, day =3D @t1.week_and_day(date)
      if week
        return [week, day]
      else
        week, day =3D @t2.week_and_day(date)
        week +=3D @t1.number_of_weeks
        return [week, day]
      end
    end
  end

I consider this very clumsy.  By _not_ combining assignment with
conditional, I cannot use "elsif".  I must split the "else" and the
"if", and turn the second conditional into a child instead of a
sibling.

Definitely less intentional and unattractive code.

Gavin