Open jyaif opened 5 years ago
It is true that we do not (yet) have the syntactic support for creating a non-generic function from a generic function by passing the type arguments (and not the value arguments). But we do have an implicit mechanism doing just that:
void foo<T>(T v) {
print(v);
}
void main() {
<int>[10,20,30].forEach(foo); // (1).
}
At (1), we implicitly obtain a function of type void Function(int)
as a 'generic function instantiation' from the generic function foo
. For more details, please consult the feature specification for that mechanism.
For example, the following code does not compile: