class ExampleClass {
var a = 0; // Not Allowed
static var b = 0; // Not Allowed
void exampleMethod() {
var c = 3; // Allowed
}
}
In the above example, both a
and b
can have their type determined at compile time. Yet, var
is allowed only for local variables whose type can inferred. Is there a design reason I'm missing as to why this is the case?
I've looked at this question which explains the use and intent behind var
, but its answer does not acknowledge reasons for the the above limitation.