> Question: Would using a constant be equally suitable for expressing > intention, and (possibly) less error-prone? I agree. But there's no law against using both: HOST = :host PORT = :port foo1 = { HOST => 'localhost', PORT => 80 } which is equally safe, simpler to read, doesn't need the ConstUtil, and automagically gives a constant with a readable string value. jf > > What a coincidence. Seems like Jim and I finally had enough of people > > conflating symbols and immutable strings on the same day. > > > > http://microjet.ath.cx/WebWiki/2005.12.27_UsingSymbolsForTheWrongReason.html > > > Question: Would using a constant be equally suitable for expressing > intention, and (possibly) less error-prone? > > # Assume ConstUtils.next_value > # ensures unique values > HOST = ConstUtils.next_value > PORT = ConstUtils.next_value > > foo1 = { > HOST => 'localhost', > PORT => 80 > } > > A downside to using symbols as constants is that this will not raise any > exceptions: > > > foo1 = { > :hots => 'localhost', > :prt => 80 > } > > But a typo in a constant will. >