From: Matthew Harris Date: 2006-06-16T21:25:24+09:00 Subject: Re: API style preference? a.b=c or a(:b=>c) I'm curious as to why you're in a position to check whether a constant is defined in the first place. On 6/16/06, Kirk Haines wrote: > 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 Haines > > -- Matt