Robert Dober wrote:

Please don't top post.

> Would it not be nice to simply extend the behavior of String#each e.g. like
> this
> 
> "Really nothing intelligent to tell".each <some_intelligent_choice> do
>           |c|
>           puts c
> end
> ==>
> R
> e
> etc. etc.
> 
> <some_intelligent_choice> might be 1 (imagine what n could do!)

We have that already: it's Enumerator.

irb(main):003:0> require 'enumerator'
=> true
irb(main):004:0> "foo\nbar".to_enum(:each_byte).each {|c| puts c.chr}
f
o
o

b
a
r
=> "foo\nbar"
irb(main):005:0> "foo\nbar".to_enum(:scan, /./m).each {|c| puts c}
f
o
o

b
a
r
=> "foo\nbar"

Cheers

	robert