Well, if you have only one argument, then arguments.count would be 1, but to 
get the argument, you’d ask for Process.arguments[0]. Arrays are zero-based.  

—  

Charles Jenkins


On Friday, November 7, 2014 at 09:30, David Wood wrote:

> (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 protected] 
> > (mailto:[email protected])> 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 protected] 
> (mailto:[email protected]))
>  
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com 
> (http://lists.apple.com)
>  
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/cejwork%40gmail.com
>  
> This email sent to [email protected] (mailto:[email protected])  

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to