2011/1/17 Pavol Klačanský <[email protected]>: > Hi, why works this? > > public class Test { > public int test; > > public Test() { > > stderr.printf("%d", test); > } > } > > why is not "this." preffix mandatory?
Basically because it doesn't need to be. Variables are searched for in various scopes in a set order, in this case: first the local (method) scope, then the current instance (this) scope. Since that finds the correct name, and there is no ambiguity, it works. If it hadn't found anything there are more scopes to search, up to the global scope. Using "this" keyword just makes it explicit what you mean, and so lots of people do that to be safe/clear. -- Phil Housley _______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
