Joel wrote:
>> What if we allow Integer#* to take a block?
>>
>> a,b,c,d,e = 5 * { Array.new }
>
> Visually nice, but some would read that as "five times array dot new",
> which is a lot like the reading of
>
>    5.times { Array.new }

I think that if we are to support this Numeric#of idea, then the above
example is (inadvertently) the best.

  a, b, c, d, e = 5.times { Array.new }

is more intuitive to me than

  a, b, c, d, e = 5.of { Array.new }

I know Integer#times is already implemented, but supporting the above
would now be incompatible.  At the moment, 5.times { whatever } returns 5.
 Surely nobody depends on that behaviour?  #times is used for its
side-effects, not its return value.

Here is a simple untested implementation which supports the existing as
well as the proposed behaviour.

  class Integer
    def times(&block)
      (0...self).map(&block)
    end
  end

  5.times { puts "Hello" }         # existing use of Integer#times
  n = 1
  6.times { |i| n = n * i }        # existing use of Integer#times
  a, b, c = 7.times { Array.new }  # *new* use of Integer#times

I can see where #of comes from, but #times is much more natural to me.

Cheers,
Gavin