[swift-evolution] Proposal: helpers for initializing properties of same name as parameters

Tal Atlas me at tal.by
Fri Dec 4 17:16:19 CST 2015


There’s lots of boilerplate of initializing structs with stored properties
and initializer parameters. I’d like to create a syntax for alleviating
that in the 90% case.

```swift
struct Foo {
    let bar: String
    let baz: Int

    init(self.bar: String = "default", counter self.baz: Int) {
    }
}
```

This would be identical to:
```swift
struct Foo {
    let bar: String
    let baz: Int

    init(bar: String = "default", counter baz: Int) {
        self.bar = bar
        self.baz = baz
    }
}
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151204/d43820f5/attachment.html>


More information about the swift-evolution mailing list