From: Jim Deville Date: 2008-11-26T03:42:29+09:00 Subject: [ruby-core:20096] Re: [Bug #796] dynamic constant assignment > -----Original Message----- > From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org] > Sent: Tuesday, November 25, 2008 10:39 AM > To: ruby-core@ruby-lang.org > Subject: [ruby-core:20095] Re: [Bug #796] dynamic constant assignment > > Hi, > > In message "Re: [ruby-core:20091] [Bug #796] dynamic constant > assignment" > on Wed, 26 Nov 2008 03:05:12 +0900, Francois Proulx lang.org> writes: > > |I understand the difference in the use of variable and constant. But > sometime you need to be able to assigned a value dynamiquely when you > are initializing your application. I see 2 possibility to address the > problem: > | > |- a interpreter's directive (which would demand a major change of the > interpreter) > |- a method to allow specificely a dynamic assignment > > You have Module#const_set, and to avoid duplicate assignment warning, > you need to remove the old constant first by Module#remove_const. > > matz. > What about a conditional dynamic assignment. It would be nice to have an idiom such as: CONST ||= "foo" I've wanted this in the initializer before, and I end up using a ternary and Module#const_set