Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Mention empty curlies #228

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions syntax.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ hierarchy easy to see:

* `}` should be the first character on the line.

It is occassionally useful to have an empty curly braces block, in which case it should be written `{}`.

```{r, eval = FALSE}
# Good
if (y < 0 && debug) {
Expand Down Expand Up @@ -320,6 +322,8 @@ tryCatch(
}
)

while (waiting_for_something()) {}

# Bad
if (y < 0 && debug) {
message("Y is negative")
Expand All @@ -333,6 +337,10 @@ if (y == 0)
message("x is negative or zero")
}
} else { y ^ x }

while (waiting_for_something()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe clarify { } is also discouraged?

while (waiting_for_something()) { }


}
```

### If statements
Expand Down
Loading