It certainly looks good to me. I believe the quiz master has
indicated we have considerable latitude in what we admit as a valid
argument sequence for DayRange#initialize.
Allowing a set of day names to be specified when an instance of
DayRange is created is a neat idea. I didn't think of that. Also, I
decided not to allow lists such as [1,3,4,5,6,7] although my
DayRange#initialize is pretty permissive in other ways. The closest I
can get to what you show is:
<code>
days = DayRange.new(1,3,4,5,6,7)
puts days
puts days.to_s(true)
</code>
<result>
Mon, Wed-Sun
Monday, Wednesday-Sunday
</result>
As you can see, I do allow optional long-form English names for days
to be returned from to_s. But your idea of allowing the programmer to
specify the names at instance creation time is better.
Regards, Morton
On Aug 26, 2006, at 11:02 AM, Robert Retzbach wrote:
> Thanks I was about to ask too.
>
> For the time being I made it this way:
>
> dayrange = DayRange.new [1,3,4,5,6,7], %w{Mo Di Mi Do Fr Sa So}
> p dayrange.to_s #=> "Mo, Mi-So"
>
> I think that's the way it should work. If not, please tell me.