Skip to content
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

[SR-10238] Ability to omit return keyword in property getter #52638

Closed
swift-ci opened this issue Mar 30, 2019 · 3 comments
Closed

[SR-10238] Ability to omit return keyword in property getter #52638

swift-ci opened this issue Mar 30, 2019 · 3 comments
Labels
compiler The Swift compiler in itself feature A feature request or implementation improvement

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10238
Radar None
Original Reporter joey (JIRA User)
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, LanguageFeatureRequest
Assignee None
Priority Medium

md5: d3f650488680b29e12a0dc87eb1486e4

Issue Description:

It would be nice if we could omit the keyword `return` in a property's getter that contains one line of code, just like you can omit it in map, filter, etc.

I propose allowing

var delimiter: String {
  get { sharedDefaults.string(forKey: "delimiter")! }
  set { sharedDefaults.set(newValue, forKey: "delimiter") }
}

Currently this is required

var delimiter: String {
 get { return sharedDefaults.string(forKey: "delimiter")! }
 set { sharedDefaults.set(newValue, forKey: "delimiter") }
}
@belkadan
Copy link
Contributor

belkadan commented Apr 1, 2019

We're discussing this right now on the forums, actually. https://forums.swift.org/t/pitch-implicit-returns-from-single-expression-functions/21898/

@swift-ci
Copy link
Collaborator Author

Comment by Michael D. Morris (JIRA)

As SE-0255 has been implemented, shouldn't this be changed to resolved?

@belkadan
Copy link
Contributor

Good call!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation improvement
Projects
None yet
Development

No branches or pull requests

2 participants