Skip to content

Instantly share code, notes, and snippets.

@Quingsley
Last active August 11, 2022 12:46
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 Quingsley/8f5d7fd5d658eabfcd43b8054732a601 to your computer and use it in GitHub Desktop.
Save Quingsley/8f5d7fd5d658eabfcd43b8054732a601 to your computer and use it in GitHub Desktop.
Dart-Generics
void main() {
var listEx = <int>[];
listEx.add(341);
listEx.add(1);
listEx.add(23);
// iterating across list listEx
for (int element in listEx) {
print(element);
}
var circleSlot = Slot<Circle>();
circleSlot.insert(Circle());
}
class Circle{
String shape = '⭕';
}
class Square{
String shape = '🟥';
}
class Slot<T>{
String shape = '';
insert(T shape){
print('I am $shape');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment