On 07.04.2007 14:48, Timothy Hunter wrote:
> Alexandre Rosenfeld wrote:
>> Hi, I'm new to ruby, and I'm loving it so far.
>>
>> I want to call a method with some parameters that would indicate a
>> state, so most of them would be only a true or false value, however
>> that's not very good to read when calling the method. Like this:
>>
>>   def dosomework(directory, overwrite = false, use_id_as_filename =
>> true)
>>
>>   dosomework('/', true, false)
>>
>> I would like to call that function with some readable parameters,
>> something like this:
>>
>>   dosomework('/', Overwrite, UseIdAsFilename)
>>
>> I have tried array arguments and hashes, but I didn't like those
>> solutions. What would be the recommended way to do that in Ruby?
>>
>> Thanks
>>
>>   
> Simple solution - just use constants
> 
> Overwrite = true
> UseIdAsFilename = false

IMHO that's not a good solution as you still have to put them in the 
proper position of the argument list.  If you use constants than they 
make more sense when using bit operations (like File).

Kind regards

	robert