Rich Collins successfully answered Joey's question:

Whats the easiest way to create an array of squares from 1..10, using default values in an Array.new?

People succeed in answering Joey's questions 57% of the time (4 successes in 7 attempts).

Answers by: Rich Collins

Rich Collins's Answer:

Chat Conversation 964 days ago

hey Joey Rich Collins at 12:09 PM on Wednesday May 17th, 2006
hmm Rich Collins at 12:09 PM on Wednesday May 17th, 2006
I need to get our next version up wher eit shows the entire question Rich Collins at 12:09 PM on Wednesday May 17th, 2006
I forgot what the end of the question was Rich Collins at 12:09 PM on Wednesday May 17th, 2006
using Array.new Joey at 12:10 PM on Wednesday May 17th, 2006
ah that is right Rich Collins at 12:10 PM on Wednesday May 17th, 2006
it doesnt have to use Array.new Joey at 12:11 PM on Wednesday May 17th, 2006
let me look at the Array.new docs - I never use default values Rich Collins at 12:11 PM on Wednesday May 17th, 2006
I just want an arry of squares from 1..10 in the shortes way Joey at 12:11 PM on Wednesday May 17th, 2006
ah got it Rich Collins at 12:12 PM on Wednesday May 17th, 2006
Array.new(10) {|i| (i + 1)* (i + 1)} Rich Collins at 12:12 PM on Wednesday May 17th, 2006
testing IRB ... Rich Collins at 12:13 PM on Wednesday May 17th, 2006
yep that did it Rich Collins at 12:13 PM on Wednesday May 17th, 2006
much shorter Joey at 12:16 PM on Wednesday May 17th, 2006
but ill give it anyway Joey at 12:16 PM on Wednesday May 17th, 2006
it was either Array.new(11){|i|i*i}-[0] Joey at 12:16 PM on Wednesday May 17th, 2006
or not using Array.new [*1..10].map{|z|z*z} Joey at 12:16 PM on Wednesday May 17th, 2006