Standard library / go/types

go/types.Union.Term()

Returns the term at a zero-based index. Expected stdout: 'string\n'.

Formal Syntax & Structure

go syntaxgo
func (u *Union) Term(i int) *Term

Parameters & Attributes

NameTypeDescription
iintZero-based member index.

Return Value

*Term

Returns the term at a zero-based index.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func union() *types.Union {  return types.NewUnion([]*types.Term{term(), types.NewTerm(false, types.Typ[types.String])})}
func term() *types.Term { return types.NewTerm(true, types.Typ[types.Int]) }
func main() { v := union(); fmt.Println(v.Term(1)) }
Go Reference