From: Rich Kilmer Date: 2001-10-27T12:58:48+09:00 Subject: [ruby-talk:23590] Re: Fast reply needed: class var trouble Its just (as in the posts below) that sometimes in the context of a method you want to call a method such as: class MyCoolClass INITIALIZING = 1 RUNNING = 2 STOPPED = 3 def status=(status) ...do funky thing based on new status beyond setting instance variable end def initialize status=INITIALIZING ...initialize stuff status=RUNNING end end In this example I want to invoke the status=(status) method but Ruby thinks I want to create a method local variable named "status" and set its value. Instead I simply code: def initialize self.status=INITIALIZING ...initialize stuff self.status=RUNNING end I have no problem with this. I am just have to be more explicit to resolve ambiguity sometimes (although rarely) when telling Ruby what I want :-) -Rich > -----Original Message----- > From: dave@thomases.com [mailto:dave@thomases.com]On Behalf Of Dave > Thomas > Sent: Friday, October 26, 2001 10:58 PM > To: ruby-talk ML > Subject: [ruby-talk:23587] Re: Fast reply needed: class var trouble > > > "Mark Hahn" writes: > > > I don't know about variable declaration as the solution, but this is > > definitely a real problem in Ruby right now. Is there anything in > > Ruby Garden that solves this ambiguity? > > I'm wondering if you're talking from some bad experiences here, or if > this is an observation based on preferences. The reason I ask is that > I've been coding Ruby for a fair while now and I've never once felt > the need to declare variables. As always, I'm interested in other > opinions. But I suspect that this is a change you're unlikely to see, > as it would change the character of the language dramatically. > > Cheers > > > Dave