Skip to content

Instantly share code, notes, and snippets.

@zapkub
Created July 29, 2021 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zapkub/352d6a8f07d041828daa62f2151c82e2 to your computer and use it in GitHub Desktop.
Save zapkub/352d6a8f07d041828daa62f2151c82e2 to your computer and use it in GitHub Desktop.
class Class1 {
int i = 0;
}
class Class2 extends Class1 {
}
void main() {
Class2 c2 = new Class2();
Class1 c1 = c2; // Class1 is inherited by Class2. so c1 as Class1 can be a subsitiution of c2
for (int i = 0; i < 5; i++) {
print('hello ${c1.i++}');
}
print('c2 value ${c2.i}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment