You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Bad
long_function_name <- function(a = "a long argument",
b = "another argument",
c = "another long argument") {
# Here it's hard to spot where the definition ends and the
# code begins
}
I basically see the point about c = having the same indentation as the function body and thus needing to scan for { at the end of a line to find the start/end of the definition.
However I think this is nicely avoided by just dropping ) { to the next line:
long_function_name <- function(
a = "a long argument",
b = "another argument",
c = "another long argument"
) {
# function body
}
I would prefer to allow this latter usage, but either weigh it would be helpful for the style guide to be explicit.
The text was updated successfully, but these errors were encountered:
long_function_name<-function(
a="a long argument",
b="another argument",
c="another long argument") {
# As usual code is indented by two spaces.
}
The main difference is that we double indent the argument list and keep ) { on the same line — this matches Google's advice for C++ and was the consensus vote amongst the tidyverse team.
Filed first as r-lib/styler#829, but in writing that I realized the style guide itself could weigh in here as well.
Currently in the style guide we have (https://style.tidyverse.org/functions.html#long-lines-1):
I basically see the point about
c =
having the same indentation as the function body and thus needing to scan for{
at the end of a line to find the start/end of the definition.However I think this is nicely avoided by just dropping
) {
to the next line:I would prefer to allow this latter usage, but either weigh it would be helpful for the style guide to be explicit.
The text was updated successfully, but these errors were encountered: