proposal: spec: "x..." in slice literal (syntactic sugar) #19218
Labels
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
Milestone
We already have a syntax to expand a slice to give as an argument to a variadic function:
slice...
. Using the same syntax in slice literals would be a consistent syntactic sugar.Would expand to:
This slice expansion should work at any place (not just the tail like for slice expansion in calls to variadic functions in Go 1.0) in the literal. Related: #18605.
Use case: building a new slice by prepending elements to a given slice is quite common when wrapping variadic functions such as
fmt.Sprintf
.The text was updated successfully, but these errors were encountered: