Oh. Thanks, Justin. I didn't know that.
On May 13, 11:31 pm, "Justin Perkins" <[EMAIL PROTECTED]> wrote:
> You want to setup those variables in the instance methods. The way you
> have it now, it's being evaluated when the class is being created (not
> instantiated) and so the variable is global to all classes.
>
> var MyClass = Class.create({
> initialize: function(someString){
> this.myVar = someString;
> },
> whatIsMyVar: function(){ alert( this.myVar ); }
>
> });
>
> new MyClass('hello').whatIsMyVar();
> new MyClass('world').whatIsMyVar();
>
> -justin
>
> On Tue, May 13, 2008 at 12:24 PM, Rauan Maemirov <[EMAIL PROTECTED]> wrote:
>
> > Hi, all.
>
> > I have class that created this way:
>
> > var MyClass = Class.create();
> > MyClass.prototype = {
> > myVar: {},
> > ...}
>
> > in this class i use it as this.myVar. So, when I create two instances
> > of this class, first instance use values from second and vice-verse.
> > Why? As U can see it's not singleton.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---