Skip to content

Commit

Permalink
Merge pull request #420 from dart-lang/fix_419_docs
Browse files Browse the repository at this point in the history
fixes #419, clarify docs around /*=T*/
  • Loading branch information
John Messerly committed Jan 26, 2016
2 parents 4eec9f5 + 0d9b50e commit 1aa4073
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/dev_compiler/GENERIC_METHODS.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ This can be written more concisely by leaving off the `dynamic`.
/*=S*/ foo/*<S>*/(/*=S*/ x) {return x;}
```

You can also put a type to the left of the `/*=T/`. This type will be used
for all non-strong mode tools. For example:

```dart
// This method works with `int`, `double`, or `num`. The return type will
// match the type of the parameters.
num/*=T*/ pickAtRandom/*<T extends num>*/(num/*=T*/ x, num/*=T*/ y) { ... }
```


Note that the generic parameter is in scope in the return type of the function,
in the argument list of the function, and in the body of the function. When
declaring local variables and parameters, you can also use the `/*=T*/` syntax with `var`.
Expand Down

0 comments on commit 1aa4073

Please sign in to comment.