We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4eec9f5 + 0d9b50e commit 1aa4073Copy full SHA for 1aa4073
pkg/dev_compiler/GENERIC_METHODS.md
@@ -84,6 +84,16 @@ This can be written more concisely by leaving off the `dynamic`.
84
/*=S*/ foo/*<S>*/(/*=S*/ x) {return x;}
85
```
86
87
+You can also put a type to the left of the `/*=T/`. This type will be used
88
+for all non-strong mode tools. For example:
89
+
90
+```dart
91
+// This method works with `int`, `double`, or `num`. The return type will
92
+// match the type of the parameters.
93
+num/*=T*/ pickAtRandom/*<T extends num>*/(num/*=T*/ x, num/*=T*/ y) { ... }
94
+```
95
96
97
Note that the generic parameter is in scope in the return type of the function,
98
in the argument list of the function, and in the body of the function. When
99
declaring local variables and parameters, you can also use the `/*=T*/` syntax with `var`.
0 commit comments