you’ll write a function that declares type parameters in
addition to its ordinary function parameters. These type parameters make the
function generic, enabling it to work with arguments of different types. You’ll
call the function with type arguments and ordinary function arguments.
Each type parameter has a type constraint that acts as a kind of meta-type
for the type parameter. Each type constraint specifies the permissible type
arguments that calling code can use for the respective type parameter.
If you want to change selection, open document below and click on "Move attachment"
Tutorial: Getting started with generics - The Go Programming Languagengle function will need a way to declare what types it supports. Calling code, on the other hand, will need a way to specify whether it is calling with an integer or float map. To support this, <span>you’ll write a function that declares type parameters in addition to its ordinary function parameters. These type parameters make the function generic, enabling it to work with arguments of different types. You’ll call the function with type arguments and ordinary function arguments. Each type parameter has a type constraint that acts as a kind of meta-type for the type parameter. Each type constraint specifies the permissible type arguments that calling code can use for the respective type parameter. While a type parameter’s constraint typically represents a set of types, at compile time the type parameter stands for a single type – the type provided as a type argument by the callin Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details