Re: Init in Swift
Re: Init in Swift
- Subject: Re: Init in Swift
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Wed, 07 Sep 2016 11:58:45 +0700
> On 7 Sep 2016, at 11:42, Quincey Morris <email@hidden> wrote:
>
> On Sep 6, 2016, at 21:31 , Gerriet M. Denkmann <email@hidden> wrote:
>>
>> My Swift book (2.2) has no mention of “private” (Swift 3 beta has).
>
> It’s in the 2.2 book under “Language Guide” section “Access Control”
You are right. I used Books.app on my iPad to search for “private” and it found only private-use Unicode code points.
Probably my iPad is broken.
>
>> But even assuming I had Swift 3, I do not quite understand how this should be done (I may be a bit dense).
>
> It’s a bit of syntactical pseudo-magic, but it makes sense when you think about it.
[…]
> In that case, you can freely change the value inside the class, but to clients of the class, it “looks like” the property is declared like this: […]
I am more concerned with methods inside my class (and compiler optimisation, which might work better, if the compiler knows something to be constant).
> This use of ‘private(set)’ doesn’t prevent you from accidentally changing the value inside the class somewhere. If you want to do that, you’re going to have to get a bit more exotic, maybe a ‘lazy’ let.
I’ll try to read about “lazy”. But right now I am myself a bit lazy and must other things first.
Thanks a lot for your help!
Kind regards,
Gerriet.
_______________________________________________
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