On Tue, Oct 6, 2009 at 16:55, dmbaggett <[email protected]> wrote:
>
> What exactly does code like this mean:
>
> qx.Class.define("my.class", {
> ...
> members: {
> foo: 1
> }
> ...
> });
>
> In particular, when will foo be initialized? Is foo now an instance
> variable
> or a class variable?
>
> foo is an instance variable. It is initialized upon instantiation of an
object of the class. However you need to be a little bit careful. In your
example, you gave foo a scaler value. If, OTOH, you had said
foo: { bar : 1 }
then the object is created only once and you get a reference to it in each
instance. If one instance does this.getFoo().bar = 23; then it will be 23 in
all instances, because they are referencing the same object. If you need
objects as member variables, the proper way to do it is to set
foo: null
in the member section, and then initialize it to a new object in the
constructor.
> The reason I ask is that in some very complicated code I am seeing behavior
> that suggests foo is a class variable, not an instance variable. In other
> words, when I call obj.hasOwnProperty('foo'), where obj is an instance of
> class my.class, I get "false".
>
That sounds like a bug, but I'm not thoroughly familiar with
hasOwnProperty().
Derrell
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel