Possible to defer initialization of let variable?
Possible to defer initialization of let variable?
- Subject: Possible to defer initialization of let variable?
- From: Rick Mann <email@hidden>
- Date: Tue, 07 Jul 2015 01:08:38 -0700
I thought I saw some Swift code that did this:
let someString : String?
if some things
{
// some stuff
someString = <a string from something>
// some other stuff
}
// use someString
But I can't get Swift 2 to let me.
Basically, I want to make someString available outside the scope in which it's initialized, but I don't want its assignment to ever change after that. I could do the former with var instead of let, of course, but I'd like it to be treated as a let after the first assignment. Is that possible?
--
Rick Mann
email@hidden
_______________________________________________
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