Skip to content

proposal: slices: add Of function #61213

Open
@FGasper

Description

@FGasper

In #47709 it was proposed to add type inference for slice literals, e.g., foo := []{"bar", "baz"}. That proposal was declined in favour of creating an equivalent function in slices.

This issue proposes a slices.Of(…) method to do that, e.g.:

foo := slices.Of("bar", "baz")

… would be equivalent to:

foo := []string{"bar", "baz"}

The benefit is minimal in a trivial case like the above, but to create a slice of *somepackage.NameThatIsRatherLong it would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions