File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1179,7 +1179,32 @@ Dart provides no way to specify a default type argument.
1179
1179
// Generic type alias
1180
1180
typedef TypeDefFoo<T> = ClassA<T>;
1181
1181
1182
+ Go
1183
+ --
1184
+
1185
+ Go uses square brackets to declare type parameters and for specialization.
1186
+ The upper bound of a type is specified after the name of the parameter, and
1187
+ must always be specified. The keyword ``any `` is used for an unbound type parameter.
1188
+
1189
+ Go doesn't support variance; all type parameters are invariant.
1190
+
1191
+ Go provides no way to specify a default type argument.
1182
1192
1193
+ .. code-block :: go
1194
+
1195
+ // Generic type without a bound
1196
+ type TypeA[T any] struct {
1197
+ t T
1198
+ }
1199
+
1200
+ // Type parameter with upper bound
1201
+ type TypeB[T SomeType1] struct { }
1202
+
1203
+ // Generic function
1204
+ func func1[T any]() { }
1205
+
1206
+ // Generic type alias
1207
+ type TypeAlias[T any] TypeA[T]
1183
1208
1184
1209
Summary
1185
1210
-------
@@ -1214,6 +1239,8 @@ Summary
1214
1239
| Dart | <> | extends | | | decl | in, out, |
1215
1240
| | | | | | | inout |
1216
1241
+------------+----------+---------+--------+----------+-----------+-----------+
1242
+ | Go | [] | T X | | | n/a | n/a |
1243
+ +------------+----------+---------+--------+----------+-----------+-----------+
1217
1244
| Python | [] | T: X | | | decl | inferred |
1218
1245
| (proposed) | | | | | | |
1219
1246
+------------+----------+---------+--------+----------+-----------+-----------+
You can’t perform that action at this time.
0 commit comments