Lovely stuff!  Thanks.  The block_given? line gives me a "stack level too deep"
error (wassat mean?) but the rest fits the bill nicely.

Is there anyplace where things like method_missing are documented?

  Mark


Dave Thomas wrote:

> How about this solution, written in Ruby, that seems to do what you
> want?
>
>      class Class
>        def method_missing(meth, *params)
>          if block_given?
>            self.new(*params).send(meth) { |*p| yield *p }
>          else
>            self.new(*params).send(meth)
>          end
>        end
>      end
>
> This is called using things like:
>
>      File.each("t.rb") { |line| puts line }
>
> By putting the handler in class Class, the technique automatically
> applies to every class in the system. And, by writing it in Ruby, you
> can make it a module that you require into your code as you
> need. Finally, it doesn't add any additional methods to the core.
>
> The downside is that you'll get weird errors if you call a real
> unknown method, so we should probably put some better error handling
> in here. That's left as an exercise...
>
> Regards
>
> Dave