let names =["Anna","Alex","Brian","Jack"]
此语法的任何其他组合都会编译.任何人知道,如果这是真的无效的语法,我们现在知道的Swift?
编辑:错误响应是:Prefix / postfix’=’被保留
答案:这段摘录似乎回答了我的问题.我只是找不到最长的时间:
The whitespace around an operator is used to determine whether an
operator is used as a prefix operator,a postfix operator,or a binary
operator. This behavior is summarized in the following rules:If an operator has whitespace around both sides or around neither
side,it is treated as a binary operator. As an example,the +
operator in a+b and a + b is treated as a binary operator. If an
operator has whitespace on the left side only,it is treated as a
prefix unary operator. As an example,the ++ operator in a ++b is
treated as a prefix unary operator. If an operator has whitespace on
the right side only,it is treated as a postfix unary operator. As an
example,the ++ operator in a++ b is treated as a postfix unary
operator. If an operator has no whitespace on the left but is followed
immediately by a dot (.),it is treated as a postfix unary operator.
As an example,the ++ operator in a++.b is treated as a postfix unary
operator (a++ . b rather than a ++ .b).
摘录自:苹果公司“Swift编程语言”iBooks. https://itun.es/us/jEUH0.l
特别是,Swift并不完全是空白无关的,特别是使用空格区分前缀和后缀操作符(因为我在C中是一个语法奇怪).但是对于像Python这样的空白来说,这也不是很荒唐.