You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- 14@jpmc26, Better? No. Valid alternative style? Of course.David Arno– David Arno2018-02-27 16:48:32 +00:00Commented Feb 27, 2018 at 16:48
- 6Better as in harder to mess up when the code is edited later, and not suffering from any notable disadvantages.jpmc26– jpmc262018-02-27 16:50:10 +00:00Commented Feb 27, 2018 at 16:50
- 4Keeping them together because of "loop contents might be long" seems to be a weak argument. When your for content is hard to read then you have other problems than saving the two lines of code.BlueWizard– BlueWizard2018-02-27 18:37:40 +00:00Commented Feb 27, 2018 at 18:37
- 12@jpmc26 Disagree. Braces are superfluous clutter in the shortest, one-liner conditionals as per this answer. Without is more elegant and easier on the eye. They're like a ternary conditional operator. I have never forgotten to add the braces while breaking them out into bigger statement blocks; I'm already adding newlines after all.benxyzzy– benxyzzy2018-02-27 19:35:00 +00:00Commented Feb 27, 2018 at 19:35
- 3It's all a style preference, but if one makes the argument that it's safer, I would disagree with that reasoning. I myself prefer without braces and on the next line, but that doesn't mean it's any more or less valid than other stylesphflack– phflack2018-02-27 19:59:34 +00:00Commented Feb 27, 2018 at 19:59
| Show 8 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you