From: Gunther Diemant Date: 2011-03-16T05:24:00+09:00 Subject: Re: Array#rotate fails in a simple program --0016e65a0dfc2dc7ac049e8b3599 Content-Type: text/plain; charset=ISO-8859-1 If upgrading isn't an option you could use each_slice from the enumerator stdlib. require 'enumerator' [2,3,5,7,11,13,17].each_slice(2) do |pair| puts pair.join(',') end #output 2,3 5,7 11,13 17 2011/3/15 RichardOnRails > 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 in http://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 > > --0016e65a0dfc2dc7ac049e8b3599--