David Kastrup
11/24/2006 11:13:00 AM
Friedrich Dominicus <just-for-news-frido@q-software-solutions.de>
writes:
> KDr2 <KDr2@163.com> writes:
>
>> Friedrich Dominicus <just-for-news-frido@q-software-solutions.de>
>> writes:
>>
>>> Zouplaz <user@domain.invalid> writes:
>>>
>>>> Hello, I don't like the verbosity of these two lines
>>>>
>>>> years = Array.new
>>>> 2003.step(Time.now.year) { |a| years << a }
>>>>
>>> years = (2003...Time.now.year+1).entries
>> maybe "a..b" is better than a...b+1 :P
>
> depends
> years = Array.new; 2003.step(Time.now.year) { |a| years << a }
> irb(main):002:0> years
> [2003, 2004, 2005, 2006]
> irb(main):003:0> years = (2003...Time.now.year+1).entries
> [2003, 2004, 2005, 2006]
> irb(main):004:0>
>
>
> I think +1 is better, YMMV
You realize that "a..b" is the same as "a...b+1"?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum