From: Miguel Regedor Date: 2009-03-15T21:32:43+09:00 Subject: Re: How do arrays in Ruby work? On Mar 14, 2:12 pm, Peter Wu wrote: > As in how they are organized behind the scenes. > > For example, if I say > > arr = [1, 2, 3, 4] > arr.slice[1] > > Is it going to have to physically relocate everything after 2 in memory? > Would using a linked list be more efficient if a lot of elements are > going to be removed and inserted? > -- > Posted viahttp://www.ruby-forum.com/. if you have the array a = [1,2,3,4,5] b = a.slice!(0,3) will end up with a == [4,5] and b == [1,2,3] b = a.slice(0,3) will end up with a == [1,2,3,4,5] and b == [1,2,3] for the last one you can also use b = a[0..2] , you will get the same result