Skip to content

Gophers v1.1.0

Latest

Choose a tag to compare

@charbz charbz released this 25 Nov 10:52
· 1 commit to main since this release
54113d6

Release v1.1.0

Features

Iterator methods

All Collections now offer a group of methods that return an iterator to the result as opposed to a new collection.
These methods can be used with the for ... range keywords to iterate over each resulting element.

  • Filtered returns an iterator to the result of a filter operation
  • Rejected returns an iterator to the result of an inverse filter operation
  • Diffed returns an iterator to the result of a diff operation
  • Intersected returns an iterator to the result of an intersection operation
  • Concatenated returns an iterator to the result of a concat operation
  • Distincted returns an iterator to the result of a distinct operation
  • Unioned returns an iterator to the result of a union operation applicable only to sets
  • Mapped returns an iterator to the result of a map operation

Example Usage:

nums := list.NewComparableList([]int{1, 2, 3, 4, 5, 6})

for i := range nums.Filtered(func(v int) bool { return v%2 == 0 }) {
  fmt.Printf("filtered %v\n", i)
}
// filtered 2
// filtered 4
// filtered 6

New methods

  • Reject is now an alias for FilterNot
  • Diff is now a method available on all collections
  • Intersect is now a method available on all collections
  • StartsWith checks wether a collection starts with a given sub-collection, available on comparable collections
  • EndsWith checks wether a collection ends with a given sub-collection, available on comparable collections

Bug Fixes

  • Fixed a bug with the Concat method for comparable collections
  • Fixed a bug with the Clone method for comparable collections
  • Fixed a bug with the Corresponds method for comparable collection

Thank you for using Gophers. If you find any issues please report them in one of the following places: