Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift error: prefix/postfix '=' is reserved [duplicate]

Tags:

ios

swift

xcode6

I am getting error message:

prefix/postfix '=' is reserved

for below simple in swift.

var c=0,a=2,b=4
c= a+b

any idea why I am getting this error?

like image 810
GMJigar Avatar asked Jun 10 '14 06:06

GMJigar


2 Answers

Check this: Is this response from the compiler valid?

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.

P.S. So you have to add whitespace before =.

like image 79
David V Avatar answered Nov 17 '22 07:11

David V


If I use a single space after variable "c" name, this error is get removed.

c = a+b
like image 2
GMJigar Avatar answered Nov 17 '22 07:11

GMJigar