Source file src/go/types/tuple.go

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

View as plain text