Re: Properties: A question of style
Re: Properties: A question of style
- Subject: Re: Properties: A question of style
- From: Charles Srstka <email@hidden>
- Date: Wed, 15 Jun 2016 12:59:17 -0500
> On Jun 14, 2016, at 8:42 PM, Steve Mills <email@hidden> wrote:
>
>> On Jun 14, 2016, at 19:45, Charles Srstka <email@hidden <mailto:email@hidden>> wrote:
>>
>> if thisArray.empty { doSomething() }
>
> That's not what he suggested as the 2nd form. Look again.
>
> Steve via iPad
Except that it is. The property name, rather than the getter, is what is expected to be used when you’re using dot syntax (and I think when calling from Swift, it’s the only way to do it).
Prepending the property name with “is” is much more clear as to what you mean, and it’s what Apple’s recommending these days (in the Swift guidelines, but that’s clearly where the future is). This helps avoid confusing things like NSURL’s .fileURL property, which is easy to scratch your head at wondering if it will query whether or not the URL is a file URL or whether it will return a converted URL (it doesn’t help that filePathURL’s name is so similar). isFileURL conveys the intent perfectly.
Charles
_______________________________________________
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