You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suspect that this is a bug: Subclasses always reference global variables instead of superclass variables with the same name.
final name ='Guest';
abstractclassPerson {
final name ='Unknown';
}
classFarmerextendsPerson {
// this uses the global nameStringget greeting =>'My name is $name';
}
classBaker {
final name ='Mr. Baker';
// this uses the local nameStringget greeting =>'My name is $name';
}
voidmain() {
final farmer =Farmer();
print(farmer.greeting);
final baker =Baker();
print(baker.greeting);
}
prints:
My name is Guest
My name is Mr. Baker
expected output:
My name is Unknown
My name is Mr. Baker
The text was updated successfully, but these errors were encountered:
I suspect that this is a bug: Subclasses always reference global variables instead of superclass variables with the same name.
prints:
expected output:
The text was updated successfully, but these errors were encountered: