Skip to content

This package provides an iterator interface and a slice iterator implementation

License

Notifications You must be signed in to change notification settings

danielgatis/go-iterator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go - Iterator

Go Report Card License MIT Go Doc

This package provides an iterator interface and a slice iterator implementation.

Install

go get -u github.com/danielgatis/go-iterator

And then import the package in your code:

import "github.com/danielgatis/go-iterator"

Example

An example described below is one of the use cases.

package main

import (
	"fmt"

	"github.com/danielgatis/go-iterator"
)

func main() {
	numbers := []int{1, 2, 3, 4, 5}
	iter := iterator.NewIterator(numbers)

	for iter.HasNext() {
		value := iter.GetNextOrDefault(0)
		fmt.Println(value)
	}
}
❯ go run main.go

License

Copyright (c) 2023-present Daniel Gatis

Licensed under MIT License

Buy me a coffee

Liked some of my work? Buy me a coffee (or more likely a beer)

Buy Me A Coffee

About

This package provides an iterator interface and a slice iterator implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages