One more little illustration:

var blah = Class.create({
someArray: [],
initialize: function() {}
});

var foo1 = new blah();
var foo2 = new blah();
foo1.someArray.push("blahblah");
alert(foo2.someArray.length); //alerts 1, most people new to js will expect
0

How many times has this issue been posted about here? People write something
like this, and expect the array to be unique for both instances, when in
fact it's shared (also known as static)... when in fact they really wanted:


var blah = Class.create({
initialize: function() {
this.someArray = [];
}
});

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to