Skip to content

[Question] NewSet vs NewSetWith #78

@ashwek

Description

@ashwek

How is NewSet different from NewSetWith?

golang-set/set.go

Lines 178 to 180 in 645e1ba

// NewSet creates and returns a reference to an empty set. Operations
// on the resulting set are thread-safe.
func NewSet(s ...interface{}) Set {

golang-set/set.go

Lines 188 to 190 in 645e1ba

// NewSetWith creates and returns a new set with the given elements.
// Operations on the resulting set are thread-safe.
func NewSetWith(elts ...interface{}) Set {

According to NewSet's documentation, it returns reference to an empty set. But that's not true. It returns reference to a set with all the items passed in parameters.

That's exactly what NewSetWith does. So how are they different?

Am i missing something here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions