From: Robert Klemme Date: 2006-12-20T00:10:12+09:00 Subject: Re: Discovering the number of return arguments requested. On 19.12.2006 12:21, Brad Phelan wrote: > Eric Hodel wrote: >> On Dec 19, 2006, at 01:20, 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. >> >> Methods only ever return one Object. (Sometimes that Object will be >> splatted, giving the illusion of multiple arguments.) > > True. However that doesn't answer the question as > to whether it is possible to discover if that single object is used > or not. I suspect Ruby syntax would make this difficult to figure > out. Actually, a Ruby method does *always* return an instance (even without explicit "return"). Conversely there is nothing like a void function / method - there is always a value returned. >> def foo() end => nil >> foo => nil > If the critical function is called as the last statement in another > function or block then the return object can get passed implicitly > up the stack until something takes hold of it. This is exactly what happens: >> def bar() 1 end => nil >> def foo() bar() end => nil >> foo => 1 >> bar => 1 IMHO you are worrying too much about this: if a method has a meaningful return value it should be documented and returned no matter what the caller does. If he chooses to ignore it that's his choice. My 0.02EUR. Kind regards robert