mirian / cosmic.com (Mirian Crzig Lennox) writes:

> So, what would be nice would be there were some way to put yield in a
> context in which all the yields could be automatically collected into
> a list, e.g.
> 
> arr = (numstrings(22, 29)).to_list
> 
> but without having to explictly write a loop and push.

For your given problem, of course, you could use

  (22..29).collect {|i| i.to_s}

but I know you're looking for a more general purpose solution.

knu's Enumerator package would let you do what you want, as you could
make your numstrings method be basis of an Enumerable object, and then
use to_a.


Regards


Dave