Re: Instantiate NSString from NSURL in Swift
Re: Instantiate NSString from NSURL in Swift
- Subject: Re: Instantiate NSString from NSURL in Swift
- From: Quincey Morris <email@hidden>
- Date: Mon, 23 Feb 2015 21:48:29 +0000
On Feb 23, 2015, at 11:52 , Kyle Sluder <email@hidden> wrote:
>
> So the type of
> foo?.lowercaseString is String?.
Yes, I agree, so the OP’s *original* error message was correct, but the question is what is the type of ‘foo?.lowercaseString!’, and that depends on the precedence of the “!” operator.
The actual error messages seem to indicate it’s associating tightly with ‘lowercaseString’, in which case the source code is incorrect and the error messages are all correct.
> And either way, the fixit diagnostic is broken.
Yes, I agree with that, too. If the tight association of “!” is correct, the fixit needs to insert parentheses.
FWIW, I think the whole thing is confusing because the internal “?” operator has a local effect (changing the type of the sub-expression to its left) and a global effect (changing the type of the whole expression). The type of ‘a?.b’ is ‘B?', isn’t it? That’s a conceptual trap for the unwary, I think.
_______________________________________________
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