This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
development:ohdsi_code_style_for_r [2017/06/09 18:45] chrisknoll |
development:ohdsi_code_style_for_r [2018/02/18 15:37] schuemie |
||
---|---|---|---|
Line 153: | Line 153: | ||
''# Plot data ---------------------------'' | ''# Plot data ---------------------------'' | ||
+ | |||
+ | ===== Curly brackets and new line ===== | ||
+ | Opening curly brackets should precede a new line. A closing curly bracket should be followed by a new line except when it is followed by ''else'' or a closing parenthesis. | ||
+ | |||
+ | **Good** | ||
+ | <code> | ||
+ | if (a == b) { | ||
+ | doSomething() | ||
+ | } else { | ||
+ | doSomethingElse() | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | **Bad** | ||
+ | <code> | ||
+ | if (a == b) | ||
+ | { | ||
+ | doSomething() | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | doSomethingElse() | ||
+ | } | ||
+ | </code> | ||
+ |