> I'm writing a number of lines lately that look something like this:
>
> DocRootNames = [nil,'docs','doc','htdocs','htdoc'].freeze unless
> const_defined? :DocrootNames

Knowing that you can do:
  @@class_state ||= 'initial_value'

Even though you can't do:
  @@class_state = @@class_state || 'initial_value'

I was going to suggest using

Constant ||= ['stuff'].freeze

But that doesn't work - it gives an uninitialised constant error (in the
same way I'd expect @@class_state ||= ... to, although it doesn't).

:)

> So, in my pre-cup-of-tea stupor this morning, I was thinking about ways
> to
> reduce the number of keystrokes to achieve that effect.
>
> I came up with two slightly different approaches:
>
> constant.DocRootNames = [nil,'docs','doc','htdocs','htdoc']
>
> or
>
> constant(:DocRootNames => [nil,'docs','doc','htdocs','htdoc'])
>
>
> I'm vacilating about whether I actually want to do either of these or
> whether
> I should just drink my cup of tea and not worry about rewriting the
> ".freeze
> unless const_defined? :Foo" boilerplate over and over again, but putting
> that
> whole consideration aside, which API style do you all like better, and
> why?

I don't like either :) If you only set up a constant in one place, and
you use require to make sure that file's only parsed once, then why
would you want that behaviour? ... There's probably a good reason, but
maybe there's a better solution to the problem?

Cheers,
  Benjohn