On Wed, Feb 1, 2012 at 1:42 PM, Gavin Sinclair <gsinclair / gmail.com> wrote: > On Wed, Feb 1, 2012 at 11:33 PM, Robert Klemme > <shortcutter / googlemail.com> wrote: >> >> There are plenty more solutions, for example: > > Both contain this, which I think is rather ugly: > >> =A0 week_and_day[0] +=3D @t1.number_of_weeks > > Ruby is beautiful for many reasons. =A0One of those is the ability to > return multiple values in a nice syntactic way. =A0These solutions are > not embracing that; they are working with an array instead of with two > values. > > Alternatives aside, what do you think of my preferred solution? On first sight it looks like it's probably the best solution for the given setting. But I cannot get rid of that nagging feeling in the back of my head that something is totally wrong here. I just can't put my finger on it. :-) Maybe it's that we have methods here which are intended to return two values but actually there is a special case of nil being returned for the _array_ of two. I can't test on 1.9.* right now but in 1.8.7 (a,b=3Dnil) is always an empty array =3D> true. So if the method returns a single value nil you probably do not get away without assigning that single value to a variable and go from there. Or you test one of the array elements only for nil. Kind regards robert --=20 remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/