Shea Martin wrote:
> Shea Martin wrote:
>> I think I know the answer to this already, but...
>>
>> Is there a what to make a block parameter mandatory?
>>
>> <code>
>> def no_block( p_str )
>>     puts "#{p_str}"
>> end
>>
>> def block( &p_block )
>>     puts "#{p_block}"
>> end
>>
>> no_block #this will cause an exception
>> block #this doesn't, but is still missing parameter?
>> </code>
>>
>> I know, I could just raise my own exception if p_block == nil, just 
>> wondering why the difference?  Or am I wrong?
>>
>> Thanks,
>>
>> ~S
> 
> I think you guys missed part of my post:
> "I know, I could just raise my own exception if p_block == nil, just
> wondering why the difference?"

That's not the same thing.  If you use block_given? as David Black and I 
suggested, there is no p_block to check for nil.

> Although thank you for reinforcing the concept of raising my own exception.

So...  You want an exception to be thrown, but you don't want to throw 
an exception?  Please show me what I've missed.  Are you saying that 
specifying the &p_block parameter should make the block mandatory 
automatically?  Hmmm...  I don't know of a way to enforce the presence 
of a mandatory block without raising any exceptions.