Sunday, 15 March 2015

swift - Is this response from the compiler valid? -



swift - Is this response from the compiler valid? -

the next code invokes error. not find info on in reference. lack of whitespace on right hand side of '=' operator error.

let names =["anna", "alex", "brian", "jack"]

any other combination of syntax compiles. know if invalid syntax per know of swift right now?

edit: error response is: prefix/postfix '=' reserved

answer: excerpt seems reply question. couldn't find longest time:

the whitespace around operator used determine whether operator used prefix operator, postfix operator, or binary operator. behavior summarized in next rules:

if operator has whitespace around both sides or around neither side, treated binary operator. example, + operator in a+b , + b treated binary operator. if operator has whitespace on left side only, treated prefix unary operator. example, ++ operator in ++b treated prefix unary operator. if operator has whitespace on right side only, treated postfix unary operator. example, ++ operator in a++ b treated postfix unary operator. if operator has no whitespace on left followed dot (.), treated postfix unary operator. example, ++ operator in a++.b treated postfix unary operator (a++ . b rather ++ .b).

excerpt from: apple inc. “the swift programming language.” ibooks. https://itun.es/us/jeuh0.l

add space after =. (=[ looks sad operator.) it's seeing =value utilize of (possible, not implemented) prefix operator.

swift isn't exclusively whitespace-agnostic c... in particular, uses whitespace distinguish prefix postfix operators (because ++i++ in c grammar oddity). it's not ridiculously strict whitespace python either.

swift

No comments:

Post a Comment