Skip to content

Conversation

rattrayalex
Copy link

Allows if (a > b) and (b > c): blah()
Disallows if (cond)result (there must be a space after the paren). This resolves ambiguities.

Expected addition to the docs:

One-line syntax with parens

While the colon syntax above is recommended, traditional styles work as well.
However, when using parens around the clauses of if, switch, with, and while,
and the body is not a block, the closing paren must be followed by whitespace.

Eg; these are legal:

if (x > 1) return

if (x > 1){
  return
}

but this is not:

if (x > 1)return

@wcjohnson
Copy link

Tested this against a code base I'm working on, no regressions. Edge cases look pretty far fetched. Looks good as far as I can see.

@rattrayalex
Copy link
Author

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants