Skip to content

Commit 1aa4073

Browse files
author
John Messerly
committed
Merge pull request #420 from dart-lang/fix_419_docs
fixes #419, clarify docs around /*=T*/
2 parents 4eec9f5 + 0d9b50e commit 1aa4073

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/dev_compiler/GENERIC_METHODS.md

+10
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ This can be written more concisely by leaving off the `dynamic`.
8484
/*=S*/ foo/*<S>*/(/*=S*/ x) {return x;}
8585
```
8686

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+
8797
Note that the generic parameter is in scope in the return type of the function,
8898
in the argument list of the function, and in the body of the function. When
8999
declaring local variables and parameters, you can also use the `/*=T*/` syntax with `var`.

0 commit comments

Comments
 (0)