github.com/bir3/gocompiler@v0.9.2202/src/go/types/tuple.go (about)

     1  // Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
     2  
     3  // Copyright 2011 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package types
     8  
     9  // A Tuple represents an ordered list of variables; a nil *Tuple is a valid (empty) tuple.
    10  // Tuples are used as components of signatures and to represent the type of multiple
    11  // assignments; they are not first class types of Go.
    12  type Tuple struct {
    13  	vars []*Var
    14  }
    15  
    16  // NewTuple returns a new tuple for the given variables.
    17  func NewTuple(x ...*Var) *Tuple {
    18  	if len(x) > 0 {
    19  		return &Tuple{vars: x}
    20  	}
    21  	return nil
    22  }
    23  
    24  // Len returns the number variables of tuple t.
    25  func (t *Tuple) Len() int {
    26  	if t != nil {
    27  		return len(t.vars)
    28  	}
    29  	return 0
    30  }
    31  
    32  // At returns the i'th variable of tuple t.
    33  func (t *Tuple) At(i int) *Var { return t.vars[i] }
    34  
    35  func (t *Tuple) Underlying() Type { return t }
    36  func (t *Tuple) String() string   { return TypeString(t, nil) }