From: RichardOnRails Date: 2011-03-16T07:10:34+09:00 Subject: Re: Array#rotate fails in a simple program On Mar 15, 11:31 am, John Feminella wrote: > > Is Array#rotate! only defined in a Ruby version later than mine?  Or > > is there something I'm missing here? > > Yes. The ruby-doc.org link is for Ruby 1.9.2. (Also, 1.8.6 is a rather > old version of Ruby, so you might want to consider upgrading anyway > even if you're not impacted by the loss of #rotate!). > > ~ jf > -- > John Feminella > Principal Consultant, BitsBuilder > LI:http://www.linkedin.com/in/johnxf > SO:http://stackoverflow.com/users/75170/ > > On Tue, Mar 15, 2011 at 11:23, RichardOnRails > > wrote: > > I'm runing Ruby 1.8.6 over WinXP-Pro/SP3 > > > I'm writing a program to illustrate prime numbers and Ruby programming > > for my teenage granddaughter.  Unfortunately, I've got a problem: > > > On line 54, I've got the statement: > > $primes.rotate!(group_size) > > > That results in the error: > > Adrienne01.rb:54: undefined method `rotate!' for [2, 3, 5, 7]:Array > > (NoMethodError) > > > However,http://www.ruby-doc.org/core/defines "ary.rotate!(cnt=1) --> > > ary" > > Also, "rotate" (without the bang) is defined in Ruby/core and fails in > > the same manner. > > > I've posted the program and its output inhttp://www.pastie.org/1674687 > > > Is Array#rotate! only defined in a Ruby version later than mine?  Or > > is there something I'm missing here? > > > Any guidance offered will be gratefully received. > > > Best wishes, > > Richard > > Thanks John: Point taken! I'm installing 1.9.2, plus Pik for switching (in a Windows environment) between Ruby versions and Rails versions. Best wishes, Richard