Mark Slagell <ms / iastate.edu> writes: > Point well taken - though, at the risk of beating a dead wildebeast here, > what I'd begun to wonder about after posting the first message was a > consistent default-semantic for instance method names when invoked as class > methods: "if no class method by that name exists, operate on a new instance > constructed with the given argument(s), if any" -- isn't it true that where > we do have duplicate class methods, this is what we generally expect to > happen anyway? Hmm. 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