From: Robert Dober Date: 2009-06-23T03:46:30+09:00 Subject: Re: regular expression gurus--help! On Mon, Jun 22, 2009 at 8:32 PM, Lloyd Linklater wrote: > Hooopo wrote: > >> require'enumerator' >>  "qwertyuiopasdfgd".scan(/./).each_cons(3){|x,y,z| p [x,y,z].join} > > I see that it will not output anything if the scan is omitted but why is > that so?  It seems that it does not buy us anything of value. Because String has a somehow strange way to implement Enumerables in 1.8 and in 1.9 there is simply no String#each_cons (because String is not an enumerable anymore) Personally I think it was a good decision, forcing people to be clear how they want the String to be "iterated" as there are some possibilities "".enum_for( x ) x in each_byte, each_char and ??? as a short for that you have x.bytes --> Enumerator x.chars --> Enumerator But David has already applied this technique in one of the replies, so I might not be DRY ;) HTH Robert Cheers > -- > Posted via http://www.ruby-forum.com/. > > -- Toutes les grandes personnes ont d’abord été des enfants, mais peu d’entre elles s’en souviennent. All adults have been children first, but not many remember. [Antoine de Saint-Exupéry]