The following code invokes an error. I could not find any information on this is in the reference. The lack of whitespace on the right hand side of the \'=\' operator is an
Add a space after the =
. (=[
looks too sad to be an operator.) It's probably seeing =value
as a use of a (possible, but not implemented) prefix operator.
Swift isn't entirely whitespace-agnostic like C... in particular, it uses whitespace to distinguish prefix from postfix operators (because ++i++
in C is a grammar oddity). But it's not ridiculously strict about whitespace like Python either.
Place a space between =
and [
,
let names = ["Anna", "Alex", "Brian", "Jack"]
It seems that =[
is a reserved operator.
Try adding a space between the =
and [
.
When the equals sign is directly in front of the bracket, the compiler assumes that you are trying to perfom a prefix operation on the array.