From: Josh Cheek Date: 2011-09-05T00:21:41+09:00 Subject: Re: loops problem --20cf30780e44a6bd9f04ac1f26b2 Content-Type: text/plain; charset=ISO-8859-1 On Sun, Sep 4, 2011 at 9:45 AM, jack jones wrote: > I've read about the method which inserts some element in a certain place > .. > what I wanted to do is to shift all the elements to the back .. not > inserting which will require rather complicated operation like deleting > the element after shifting it .... I really don't understand the line > you wrote, thank you :) > > -- > Posted via http://www.ruby-forum.com/. > > Insert nil. There are lots of options for docs. rdoc.info: http://rdoc.info/stdlib/core/1.9.2/Array#insert-instance_method ruby-doc.org: http://ruby-doc.org/core/classes/Array.html#M000230 And you can't have an array with a "gap" in it. ie what is returned if you access that index after you've shifted the elements? The obvious answer is nil, so just insert nil: array = (0..10).to_a counter = 5 array.insert counter, nil array # => [0, 1, 2, 3, 4, nil, 5, 6, 7, 8, 9, 10] --20cf30780e44a6bd9f04ac1f26b2--