Re: Satisfying a protocol - getters vs. functions
Re: Satisfying a protocol - getters vs. functions
- Subject: Re: Satisfying a protocol - getters vs. functions
- From: Quincey Morris <email@hidden>
- Date: Sat, 25 Jun 2016 12:10:08 -0700
- Feedback-id: 167118m:167118agrif8a:167118sypJLVT7Dd:SMTPCORP
On Jun 25, 2016, at 11:59 , William Squires <email@hidden> wrote:
>
> But would it make a difference if you have a getter named description that has type String?
They’re not interchangeable in Swift. The semantics are not even the same: getters aren’t allowed to mutate instance variables, for example (enforced by the compiler). Getters also can’t throw (though they’re talking about adding this in a later version of Swift.)
Also, the names are distinct. You won’t see that in non-mangled form, but if you think in terms of selectors, the Swift 3 selector for a function named “description" is #selector(description), while the selector a getter for a property named “description” is #selector(getter:description).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden