Re: Nil Coalescing and Optional Chaining?
Re: Nil Coalescing and Optional Chaining?
- Subject: Re: Nil Coalescing and Optional Chaining?
- From: David Wood <email@hidden>
- Date: Fri, 07 Nov 2014 09:30:55 -0500
(Dagnabbed mailing list didn’t set the ReplyTo field! What’s up with that?)
> On Nov 7, 2014, at 8:57 AM, Charles Jenkins <email@hidden> wrote:
>
> It looks to me like Process.arguments[] does not return an optional value. I think you need to find out how many elements are in the array before attempting to access them by an index.
>
> —
>
> Charles Jenkins
Sadly, that’s what I gather too. So it looks like there’s no way to work an array subscript into an optional chain, for safeguarding purposes.
Strangely, this new construction also fails, and for the same reason too:
var inputValue = (Process.arguments.count > 0) ? Process.arguments[1].toInt()! : defaultValue
“fatal error: Array index out of range”
I’m running it now from inside XCode, so there are no arguments; would that be a problem?
_______________________________________________
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