underscore
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

UniqueInPlace

UniqueInPlace removes duplicates from a slice in place while preserving order. Returns the shortened slice.

package main

import (
 "fmt"
 u "github.com/rjNemo/underscore"
)

func main() {
 xs := []int{1,4,2,5,3,1,5,2}
 fmt.Println(u.UniqueInPlace(xs)) // [1 4 2 5 3]
}