Generics

Partial explicit type arguments

A generic function call may provide a prefix of its type argument list and infer the remaining arguments from call arguments and constraints. Omitted arguments must be inferable; type arguments cannot be skipped in the middle. Example output: '3 go'.

Formal Syntax & Structure

go syntaxgo
Convert[int](value)

Working Example

Example Snippetgo
package main
import "fmt"
func pair[A, B any](a A, b B) (A, B) { return a, b }func main() {  fmt.Println(pair[int](3, "go"))}
Go Reference