| OLD | NEW |
| 1 # Strong mode generic method prototype syntax | 1 # Strong mode generic method prototype syntax |
| 2 | 2 |
| 3 This is a summary of the current (as of January 2016) supported comment-based | 3 This is a summary of the current (as of January 2016) comment-based generic |
| 4 generic method syntax supported by the analyzer strong mode and the Dart Dev | 4 method syntax supported by the analyzer strong mode and the Dart Dev Compiler. |
| 5 Compiler. The comment-based syntax essentially uses the proposed actual generic | 5 The comment-based syntax essentially uses the proposed actual generic method |
| 6 method syntax, but wraps it in comments. This allows developers to experiment | 6 syntax, but wraps it in comments. This allows developers to experiment with |
| 7 with generic methods while still ensuring that their code runs on all platforms | 7 generic methods while still ensuring that their code runs on all platforms while |
| 8 while generic methods are still being evaluated for inclusion into the language. | 8 generic methods are still being evaluated for inclusion into the language. |
| 9 | 9 |
| 10 ## Declaring generic method parameters | 10 ## Declaring generic method parameters |
| 11 | 11 |
| 12 Generic method parameters are listed after the method or function name, inside | 12 Generic method parameters are listed using a block comment after the method or |
| 13 of angle brackets and comments. | 13 function name, inside of angle brackets. |
| 14 | 14 |
| 15 ```dart | 15 ```dart |
| 16 // This declares a function which takes two unused generic method parameters | 16 // This declares a function which takes two unused generic method parameters |
| 17 int f/*<S, T>*/(int x) => 3; | 17 int f/*<S, T>*/(int x) => 3; |
| 18 ``` | 18 ``` |
| 19 | 19 |
| 20 As with classes, you can put bounds on type parameters. | 20 As with classes, you can put bounds on type parameters. |
| 21 | 21 |
| 22 ```dart | 22 ```dart |
| 23 // This declares a function which takes two unused generic method parameters | 23 // This declares a function which takes two unused generic method parameters |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 C c = new C(); | 181 C c = new C(); |
| 182 // This line will produce a type error, because strong mode will infer | 182 // This line will produce a type error, because strong mode will infer |
| 183 // `int` as the generic argument to fill in for S | 183 // `int` as the generic argument to fill in for S |
| 184 String x = c.inferableFromArgument(3); | 184 String x = c.inferableFromArgument(3); |
| 185 | 185 |
| 186 // This line will produce a type error in strong mode, because `int` is | 186 // This line will produce a type error in strong mode, because `int` is |
| 187 // explicitly passed in as the argument to use for S | 187 // explicitly passed in as the argument to use for S |
| 188 String y = c.notInferable/*<int>*/(3); | 188 String y = c.notInferable/*<int>*/(3); |
| 189 } | 189 } |
| 190 ``` | 190 ``` |
| OLD | NEW |