I’m writing a number of lines lately that look something like this:
DocRootNames = [nil,‘docs’,‘doc’,‘htdocs’,‘htdoc’].freeze unless
const_defined? :DocrootNames
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?
Kirk H.