From: Hugh Sasse Staff Elec Eng Date: 2003-01-08T23:45:16+09:00 Subject: Re: Can you detect if a method takes a block argument? On Wed, 8 Jan 2003, Martin Weber wrote: > Quick shot, suppose ruby wizards can make this still better. > > def use_block?(invoke) > catch (:block) do > eval "#{invoke} do > throw :block, true > end" > end or false > end Nice. The only problem is that if the function has side effects data may be (adversely?) affected. But there is a further problem with the whole question, I feel. If you know the method takes a block, you need to know what it does with the block -- i.e semantics. Does it use the block once or many times, etc? So to be able to do anything useful with the knowledge that "this method takes a block", you need more information than that. If you have this further information you will already know that it does/doesn't use a block. In other words, how can the information that a method uses a block be sufficient knowledge to use that method correctly? Hugh