From: Henry Maddocks Date: 2013-03-26T09:03:42+09:00 Subject: Re: Choice of methods/implementation (was: Writing a game, trying to make dynamic loops) --Apple-Mail=_57EDC0B1-BA40-4884-A8E3-7740DFFC3D72 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 On 26/03/2013, at 11:04 AM, Robert Klemme = wrote: >> I don't very much like the previous Array.new() {} either, although >> being 1-based might be easier for some to understand, but breaks my >> oh-so-long-established zero-based array mentality. I'd have = approached >> this with #reduce. I'd appreciate hearing your thoughts on the >> trade-offs. >=20 > Which previous Array.new {} do you mean? The one with the separate > counter variable? >=20 > I don't think this calls for #inject / #reduce. IMHO #map is a better > choice here since you do not need to explicitly deal with the Array > copied into. I like to think of 'reduce' meaning you have several things that you = want to reduce to a single thing whereas with 'map' you are mapping one = thing to another thing, e.g. mapping integers to players. Henry --Apple-Mail=_57EDC0B1-BA40-4884-A8E3-7740DFFC3D72 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=iso-8859-1 shortcutter@googlemail.com&= gt; wrote:
I = don't very much like the previous Array.new() {} either, = although
being 1-based might be easier for some to understand, but = breaks my
oh-so-long-established zero-based array mentality. I'd have = approached
this with #reduce. I'd appreciate hearing your thoughts on = the
trade-offs.

Which previous Array.new {} = do you mean?  The one with the separate

choice here since you do not need to = explicitly deal with the Array
copied into.