From: ara.t.howard@... Date: 2006-12-19T23:51:56+09:00 Subject: Re: Discovering the number of return arguments requested. On Tue, 19 Dec 2006, Brad Phelan wrote: > Is it possible ( and I think not ) that you can discover if any return > arguments are requested when a method is called. > > Eg: > > def foo > if nargout == 1 > "bar" > end > end > > a = foo # nargout == 1 > foo # nargout == 0 > > > This would be useful in certain patterns where you only want to > create a return value and consequently a new object if it is > actually required. just build that pattern into your interface: harp:~ > cat a.rb def foo opts = {} dst = opts['dst'] || opts[:dst] dst << 'bar' unless dst.nil? end foo :dst => a='' # nargout == 1 p a foo # nargout == 0 harp:~ > ruby a.rb "bar" of course you could do alot more too. -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