Wednesday, December 06, 2006

Ruby : Defaulted optional arguments

I'd seen this technique, but I'd lost it.

def placeholder(requiredarg, options = {})
  # set default options
  o = { :class => 'placeholder', :tag => 'p' }.merge(options)

  ...
end

1 comment:

Gishu said...

thanks... i forgot this one too..
making a note myself