Jan Hudec wrote:
> 
> On Tue, January 5, 2010 13:12, Frederik wrote:
>> You have several options:
>>
>> - create a throw-away instance:
>>
>>   static int main (string[] args) {
>>       new Global ();
>>       stdout.printf ("all data is in: " + Global.dataDir);
>>       return 0;
>>   }
> 
> Actually, there is no need to do that -- calling typeof(Global); is enough.

No, I have tried that. I thought so, too, but it doesn't work.

>> - call a static initialization method:
>>
>>   static int main (string[] args) {
>>       Global.init ();
>>       stdout.printf ("all data is in: " + Global.dataDir);
>>       return 0;
>>   }
> 
> This should not work. *static* methods do not cause a class to be
> initialized (*class* methods do, though).

I was under the impression that class methods are called 'static'
methods in Vala/Java/C#.

>> - make 'dataDir' const, if it is not intended to change
> 
> - make the variable a class one instead of static one.
> 
> public class Global {
>     class string dataDir = "whatever";
> }
> 

This does not compile.


Best regards,

Frederik
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to