tuple

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func First

func First[T any, V any](t Tuple[T, V]) T

First returns the first element of the tuple.

func Second

func Second[T any, V any](t Tuple[T, V]) V

Second returns the second value of the tuple.

Types

type Tuple

type Tuple[T any, V any] struct {
	// contains filtered or unexported fields
}

Tuple is a structure which contains two distinct values. These values are typically used for representing key/values pairs of maps. Other useful uses for tuples are for representing element/error paris.

func New

func New[T any, V any](t T, v V) Tuple[T, V]

New creates a new Tuple with the given values. It takes two parameters, `t` and `v`, of any type `T` and `V` respectively, and returns a Tuple[T, V] with the `t` value assigned to the `first` field and the `v` value assigned to the `second` field.

func (Tuple[T, V]) First

func (t Tuple[T, V]) First() T

First returns the first element of the tuple.

func (Tuple[T, V]) Second

func (t Tuple[T, V]) Second() V

Second returns the second value of the tuple.

func (Tuple[T, V]) Unpack

func (t Tuple[T, V]) Unpack() (T, V)

Unpack returns the values of the Tuple.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL