github.com/enetx/g@v1.0.80/examples/iter/iter_unique.go (about)

     1  package main
     2  
     3  import "github.com/enetx/g"
     4  
     5  func main() {
     6  	// Create a slice of strings
     7  	g.SliceOf("bbb", "ddd", "bbb", "aaa", "xxx", "bbb", "bbb", "xxx", "ddd", "bbb", "aaa", "bbb").
     8  		Iter().
     9  		Unique().  // Filter out duplicate elements
    10  		Collect(). // Collect the unique elements
    11  		Print()    // Print the collected unique elements: Slice[bbb, ddd, aaa, xxx]
    12  }