lazy

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lazy

type Lazy[T any] interface {
	// Get returns the value, evaluate it if necessary.
	Get() T
	// Evaluated returns whether the value has been evaluated or not.
	Evaluated() bool
}

Lazy defers the evaluation of getter until it's accessed the first access.

func New

func New[T any](getter func() T) Lazy[T]

New returns a new lazily evaluated value. The getter is executed only when it's accessed the first access.

Jump to

Keyboard shortcuts

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