From: "v.nainar" Date: 2005-09-28T16:46:28+09:00 Subject: Re: class variables On Wed, Sep 28, 2005 at 03:52:54PM +0900, Kevin Brown wrote: > On Wednesday 28 September 2005 00:03, v.nainar wrote: > > Hello! > > > > What is wrong with the following code? Why is @@id incremented before > > and not after the assignment? . ( Sorry if this sounds silly and I have > > overlooked something obvious ) ------- > > # # why is @id not 1 > > # # and 2 > > # # and 3 ? > > When somethings at the end of a function, it gets returned implicitly. So, > when you call @id - setId() you're setting @id to the current id (1), then > incrementing, and then then function returns the incremented value, > overwriting your 1 with a 2. Throw a return @s at the end and you'll get the > behaviour you're looking for. > > > Well it **was** silly of me .Thanks for the quick replies