...

Source file src/cmd/compile/internal/types2/tuple.go

Documentation: cmd/compile/internal/types2

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

View as plain text