re: How do you feel about braces and semicolons? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: No-semicolons are a problem IFF expressions can be statements (not sure about the terminology here). For example foo = bar - baz could be...
 

The way Swift handles this is interesting.

let x = 10
- 1
// is
let x = 10
- 1;

let x = 10
-1
// is
let x = 10;
-1;

let x = 10 - 1
// is
let x = 10 - 1;

let x = 10 -1
// is
let x = 10; -1;
// Error two statements on the same line must be separated by a semicolon

The rule is basically [space][op][space] or [nospace][op][nospace] is an infix operator, [space][op][nospace] is a prefix operator, and [nospace][op][space] is a postfix operator.

code of conduct - report abuse