From: Michael Ehehalt Date: 2005-09-22T21:26:39+09:00 Subject: Re: hi, i'm new. plus one question Hi, the code: idea = ["a","b","c","d"] idea.push( idea.shift ) lets the array rotate to the left and returns ["b", "c", "d", "a"] the code: idea = ["a","b","c","d"] idea.unshift( idea.pop ) p idea lets rotate to the right and returns: ["d", "a", "b", "c"] Is this what you mean? Michael "travis laduke" schrieb im Newsbeitrag news:7501E02B-A490-423F-B99B-8EF43D1CA11F@socal.rr.com... > I've been forced to work on some php lately and found myself thinking: > "man, this sucks. i wish it was more like supercollider" > then i remembered supercollider is ruby-influenced so i started reading > about ruby. > > Here's my question: is there a common way to rotate a string or an array? > > I thought i could do some combination of .pop and .unshift or something, > but i ran into this problem: > > idea = ["a","b","c","d"] > x = idea.pop > puts idea > > why is idea changed? how do i make it stay the same? > why is it different than: > > x = idea.reverse > > where idea is left alone and only x is the reversed array? > > > > -travis > >