Generics
Type parameters with bounds make reusable classes and functions.
Example
class Box<T> {
final T value;
Box(this.value);
}
T first<T>(List<T> l) => l[0];
void main() {
print(Box(5).value);
print(first(["a", "b"]));
}Exercise
Type parameter.
class Box<> {}
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.