This is a companion discussion topic for the original entry at https://www.kodeco.com/30303825-programming-in-dart-functions-closures/lessons/16
This is a companion discussion topic for the original entry at https://www.kodeco.com/30303825-programming-in-dart-functions-closures/lessons/16
I thought it was surprising that T didn’t enforce the same type for all list entries. For example, you can also pass a mix of types to the function.
void main() {
var myList = toList(1, 3.14, 'bar');
print(myList);
}
List<T> toList<T>(T item1, T item2, T item3) {
return <T>[item1, item2, item3];
}
So because I’m passing in different types, the T effectively becomes dynamic at runtime?