[RCR] Numeric#of

Joel VanderWerf [mailto:vjoel@PATH.Berkeley.EDU] commented:

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 }

so maybe, we’d want rather

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

?

Peña, Botp wrote:

Joel VanderWerf [mailto:vjoel@PATH.Berkeley.EDU] commented:

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 }

so maybe, we’d want rather

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

?

Not IMO. I still like the other much better.

It seems clear that the result of x*y is “always” an expression;
I don’t think we expect it to iterate as #times does.

Although I grant you, they’re pronounced the same. If you ever
dictate your code to someone over the phone, it could be a
problem. :stuck_out_tongue:

Hal

Hal Fulton wrote:

Peña, Botp wrote:

Joel VanderWerf [mailto:vjoel@PATH.Berkeley.EDU] commented:

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 }

so maybe, we’d want rather

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

?

Not IMO. I still like the other much better.

It seems clear that the result of x*y is “always” an expression;
I don’t think we expect it to iterate as #times does.

Although I grant you, they’re pronounced the same. If you ever
dictate your code to someone over the phone, it could be a
problem. :stuck_out_tongue:

Actually I guess both these are bad syntax. You would have to
use proc, I suppose.

a,b,c = 3 * proc { Array.new }

And suddenly it seems like more trouble than it is worth.

Hal

Hal Fulton wrote:

Although I grant you, they’re pronounced the same. If you ever
dictate your code to someone over the phone, it could be a
problem. :stuck_out_tongue:

Low tech pair programming–it happens.