O'Reilly logo
  • Ronald Cosentino thinks this is interesting:

>> order_two = Array.new(3, 'sunny_side_up_egg')
=> ["sunny_side_up_egg", "sunny_side_up_egg", "sunny_side_up_egg"]

“Here, we’re calling the new method on Array, which creates a list of items. The next part in the parentheses means that the array should have three items,” Scarlet explained, “and the last part means that each item should be a 'sunny_side_up_egg'. It’s the same as typing all the stuff we did for order_one.”

From

Cover of Ruby Wizardry

Note

Quick way to create a new array. Array.new(3,"sunny_side_up_egg")