On 07.04.2007 07:47, 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?

There are tons of ways.  You could use bit mapped flags (see File or 
Regexp for example).  Or you use a Hash like this

do_some_work('/', :overwrite => true, :use_id_as_filename => true)

Kind regards

	robert