Ian Macdonald <ian / caliban.org> wrote in message news:<20040123174504.GY27623 / caliban.org>... > Hello, > > Does anyone know of a way to detect whether default parameters are being > used in a method? I'm looking for something like the pseudo-method > 'default?' in the following example: > > def my_method(foo='bar') > if foo.default? > puts "warning: default value #{foo} being used for 'foo'" > end > end > > I suspect Ruby no longer holds any state at this point to reflect the > fact that the caller did not supply a parameter, but I'm hoping there's > some way to do it. > I doubt there would be any way to actually implement #default? as you show. You could do it this way, I suppose, but it's probably not what you're looking for: def my_method(foo='bar') if(foo=='bar') puts "warning: default value #{foo} being used for 'foo'" end end What is it you're trying to accomplish? Perhaps there's a different way to do it. Phil