Alan Hoo Alan Hoo - 3 months ago 9
Swift Question

Why Swift cannot remove spaces when compiling code?

Quite new to Swift, compared to Java and C++...I'm just wondering why Swift doesn't remove spaces when compiling code as following:

if x!=10 {...} //I have to add space before and after != to get rid of issue.


Increment like increment++ as well can not be act as increment in For syntax if I don't put a space between increment++ and { of loop block.

As in Java or C++, space and Tab do not make sense in terms of compiling. Is Swift just like Python in the way of consider space or tab as part of code?

M_G M_G
Answer

The exclamation mark is not only used as not for example. It is also used to unwrap an optional variable.

There is more syntactic difference to other languages.

Comments