[chuck-users] Static attributes and instantiation

Gonzalo gonzalo at dense13.com
Wed Oct 22 22:56:28 EDT 2014


Hi,

This is weird behavior I think:

--------------------
public class Foo {
   1 => static int bar;
}

<<< Foo.bar >>>; // prints 0! Why?

Foo f;
<<< Foo.bar >>>;  // prints 1, ok

2 => Foo.bar;
<<< Foo.bar >>>;  // prints 2, ok

Foo f2;
<<< Foo.bar >>>; // prints 1 again!
--------------------

So it seems that static members get initialized only on instantiation, 
but to make it funky, on every instantiation...

Is this a buggy implementation of static members, or am I missing 
something? Not complaining, just a question. :)

Thanks!
Gonzalo


More information about the chuck-users mailing list