From: Dave Thomas Date: 2008-08-30T08:37:53+09:00 Subject: Re: cycle in Ruby 1.9? On Aug 29, 2008, at 6:25 PM, Charles Turner wrote: > I've seen a number of references to being able to pass an argument to > cycle() to limit its behavior to a finite number of iterations. > However, I get this in irb 1.9.0: > > ruby 1.9.0 (2007-12-25 revision 14709) [i686-darwin9.4.0] > spinoza:~$ irb > irb(main):001:0> ('a'..'c').cycle(2) > ArgumentError: wrong number of arguments(1 for 0) Ruby 1.9 has changed a lot since Christmas. Here's the same code running on a build based on today's HEAD: dave[RUBY3/Book 18:41:43*] ruby -ve "p(('a'..'c').cycle(2))" ruby 1.9.0 (2008-08-30 revision 15427) [i386-darwin9.4.0] # Expanding the Enumerator gives dave[RUBY3/Book 18:41:49*] ruby -ve "p(('a'..'c').cycle(2).to_a)" ruby 1.9.0 (2008-08-30 revision 15427) [i386-darwin9.4.0] ["a", "b", "c", "a", "b", "c"] Cheers Dave