-
Notifications
You must be signed in to change notification settings - Fork 439
ArrayExprSyntax
initializer that takes an array of ExprSyntax
#1674
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
Comments
Tracked in Apple’s issue tracker as rdar://109483386 |
Is it okay for me to handle this issue? |
Hi @grynspan! Would you be able to achieve your request with the result builder initialiser of Maybe something like return ArrayExprSyntax {
for item in [1, 2, 3, 4] {
ArrayElementSyntax(expression: ExprSyntax("\(raw: item)"))
}
} |
Sure, I assigned it to you.
To speak on @grynspan’s behalf: The motivating example here is where you already have an ArrayExprSyntax {
for element in arrayElements {
element
}
} |
Yes! However it seems like a convenience initializer here is worth implementing, because "constructing an |
Description
Constructing an
ArrayExprSyntax
from a Swift array of arbitraryExprSyntax
values is a bit of a pain. Right now, we do silly dances like:Having a convenience initializer that inserts commas and necessary trailing trivia would make this much nicer.
The text was updated successfully, but these errors were encountered: