Max Williams wrote:
> I'm using the method of parameter passing where i have one 'regular'
> parameter and then a hash of options:
> 
> def chunkify(something, options = {})
>   ...
> end
> 
> I want to have it so that the user can just pass a key through without
> having to set it to anything, eg
> 
> dinner = chunkify(bacon, :extra_fine)
> 
> However, 'extra_fine' is just being treated as a symbol, rather than a
> hash key, and so 'options' is simply the symbol :extra_fine, rather than
> the hash {:extra_fine => nil}.
>
extra_fine is a symbol, as other people pointed out.

If that's the only concern, then how about

def chunkify(something, options={})
  options={options=>true} unless options.kind_of(Hash)
  ....

end

options=:extra_fine  ;=>  :extra_fine
options={options=>true} unless options.kind_of?(Hash) 
;=>{:extra_fine=>true}

Then your normal processing can continue.

-- 
Posted via http://www.ruby-forum.com/.