From: Charles Mills Date: 2004-11-06T03:20:12+09:00 Subject: Re: value provided for argument with default value - how to check inside method? On Nov 5, 2004, at 9:54 AM, Charles Mills wrote: > On Nov 4, 2004, at 8:03 PM, itsme213 wrote: > >> Is there an equivalent of block_given? to check if the caller >> provided a >> value to an argument that had a default value? >> >> Or do I have to use some sentinel value? > > I remember Nobu had a solution for this... I can't seem to find it > though. I think it was something like this: > > > def foo(x=(nil; a=true)) > > puts a > > end > => nil > > foo() > true > => nil > > foo('value') > nil > => nil > > You can replace nil with the default value you want. > a will be set to true if a value is passed in, nil otherwise. ----- I meant "unless a value is passed in"