From: ara.t.howard@... Date: 2007-01-03T04:51:15+09:00 Subject: Re: Detecting default used in method calls On Wed, 3 Jan 2007, Peter Lynch wrote: > I would like to know if a function has been called with or without an > optional argument. > > If I have - > > def the_Function (a, b = '') > end > > and I invoke it like this - > > the_Function('a') > the_Function('a', '') > > is there any way for me to tell within the_Function which form of > invocation was used? def the_function *a, &b case a.size when 0 p 'zero args' when 1 p 'one arg' when 2 p 'two args' else raise ArgumentError end # ... end but methods like this are often confusing to read the_function 'arg' the_function 'arg', 'wtf does this do?' it's often better and more rubyish to use options def the_function arg, opts = {}, &block b = opts['b'] || opts[:b] # .... end regards. -a -- if you find yourself slandering anybody, first imagine that your mouth is filled with excrement. it will break you of the habit quickly enough. - the dalai lama