Arrays
suggest changeSyntax
a = []creates an array with an array literal.a = Array.newis equivalent to the literal.a = Array.new(5)creates an array of 5 elements, eachnil.a = Array.new(5, 0)creates an array of 5 elements with the default value0. The same default object is reused for every slot, so do not pass a mutable object.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents