| // Copyright 2011 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| package types2 |
| |
| // A Tuple represents an ordered list of variables; a nil *Tuple is a valid (empty) tuple. |
| // Tuples are used as components of signatures and to represent the type of multiple |
| // assignments; they are not first class types of Go. |
| type Tuple struct { |
| vars []*Var |
| } |
| |
| // NewTuple returns a new tuple for the given variables. |
| func NewTuple(x ...*Var) *Tuple { |
| if len(x) > 0 { |
| return &Tuple{vars: x} |
| } |
| return nil |
| } |
| |
| // Len returns the number variables of tuple t. |
| func (t *Tuple) Len() int { |
| if t != nil { |
| return len(t.vars) |
| } |
| return 0 |
| } |
| |
| // At returns the i'th variable of tuple t. |
| func (t *Tuple) At(i int) *Var { return t.vars[i] } |
| |
| func (t *Tuple) Underlying() Type { return t } |
| func (t *Tuple) String() string { return TypeString(t, nil) } |