On Wed, 26 May 2004 17:07:11 +0900, Simon Strandgaard wrote:

Hi,

> Martin DeMello <martindemello / yahoo.com> wrote:
>> Simon Strandgaard <neoneye / adslhome.dk> wrote:
>> > Simon Strandgaard <neoneye / adslhome.dk> wrote:
>> > [snip] 
>> > > Your 'of' is a mix between times and map. Wouldn't it be better to
>> > > name it 'times_map' ?
>> > > 
>> > 
>> > Even simpler.. it would make sense to me if it were just named 'maps'
>> > 
>> >   a, b, c = 3.maps {|n| -n}
>> >   # a=0, b=-1, c=-2
>> 
>> Or even just map (there's no Numeric#map) - I don't like that either
>> [ruby-talk:62177] but I can't think of anything I like better.
> 
> Agree, Numeric.map would be perfect.
>  
> irb(main):001:0> (2..4).map{|i| -i}
> => [-2, -3, -4]
> irb(main):002:0> 5.map{|i| -i}
> NoMethodError: undefined method `map' for 5:Fixnum
>         from (irb):2
> irb(main):003:0>

I feel that an integer represents only that integer,
not a range, I mean, that's where ranges are for, isn't it?
More logical would be 4.map{ |i| -i } to return [-4].
Times_map I find more accurate, but is it necessary?
What's wrong with Array.new(3){ |i| -i } or 
(0..2).map{ |i| -i } ?
For small values it is even faster to type
  a, b, c = 0, -1, -2
and more clear IMO than
  a, b, c = 3.map { |i| -i }

Cheers,
Kristof

PS. I wonder if my messages make it to the newsgroup,
I can see only half of the postings people send...