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
rm...@latencyzero.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to