Skip to content

Instantly share code, notes, and snippets.

@mg
Created January 10, 2014 09:42
Show Gist options
  • Save mg/8349210 to your computer and use it in GitHub Desktop.
Save mg/8349210 to your computer and use it in GitHub Desktop.
func NewSetFromSlice(s interface{}) Set {
a := NewSet()
slice := reflect.ValueOf(s)
for i := 0; i < slice.Len(); i++ {
a.Add(slice.Index(i).Interface())
}
return a
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment