-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: spec: "x..." in slice literal (syntactic sugar) #19218
Comments
|
Why isn't #18605 enough? This would complicate the language and would be a much bigger change to it. |
This is what
(*) assuming we know the type The above requires In other words, we already have the functionality you wish for, perhaps a bit less elegantly, but more explicitly, with I am against this proposal. |
I don't want this feature anymore. @yaxinlx and @griesemer convinced me. |
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: