Skip to content

Add a proposal for a string interpolation default parameter #2772

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

Merged
merged 2 commits into from
Apr 16, 2025

Conversation

natecook1000
Copy link
Member

A new string interpolation syntax for providing a default string when interpolating an optional value.

let age: Int? = nil
print("Your age: \(age, default: "missing")")
// Prints "Your age: missing"

@rjmccall rjmccall added the LSG Contains topics under the domain of the Language Steering Group label Apr 14, 2025
@xwu
Copy link
Contributor

xwu commented Apr 15, 2025

@natecook1000 Happy to kick off review whenever—if you'd like a chance to tack on a paragraph about Either as an alternative/future direction, I can wait for that. Let me know!

@xwu xwu merged commit dbcea32 into swiftlang:main Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LSG Contains topics under the domain of the Language Steering Group
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants