Re: Help with Swift changes to optionals
Re: Help with Swift changes to optionals
- Subject: Re: Help with Swift changes to optionals
- From: Rick Mann <email@hidden>
- Date: Wed, 15 Apr 2015 13:22:09 -0700
> On Apr 15, 2015, at 12:47 , Marco S Hyman <email@hidden> wrote:
>
>
>> On Apr 15, 2015, at 12:29 PM, Rick Mann <email@hidden> wrote:
>>
>> I used to have this code prior to 1.2, which compiled and ran fine, but now I get an error on the last line:
>>
>> '?' must be followed by a call, member lookup, or subscript
>
> …
>
>>
>> var query : String?;
>
>>
>> log("query: '\(query?)'”);
>
> Use
>
> log("query: '\(query)'”);
>
> If query is nil the result will be “query: ‘nil’” because string interpolation
> works with optionals.
I stand corrected; that *does* work. I think I fell victim to Xcode showing me an error because although it worked in the current target, I had not yet rebuilt another target, so it was still showing the error (I REALLY hate Xcode's error reporting).
Thanks!
--
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