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
I sometimes find the following type of usage to be appropriate for "implicit" assignment:
if (any(idx <- x > 0)) {
stop("Found positive entries: [", toString(which(idx)), "]")
}
The object idx is not used outside the branch, so I think it can be distracting to define it in the "main" body of the function. I believe @IndrajeetPatil has a cite on this being good practice in some contexts too.
It would be nice to allow this sort of implicit assignment, defined by the object of assignment is (1) inside if and (2) only referenced inside that if's parent <expr>.
This argument (let's say allow_scoped_if_assignment) would be FALSE by default since the style guide does not consider this exception.
The text was updated successfully, but these errors were encountered:
One question is whether foo(x <- 1) should be linted if x is not referenced anywhere else in the code. I think yes (esp. since this is a common mistake where = was intended), but it will make implementation a bit harder.
I sometimes find the following type of usage to be appropriate for "implicit" assignment:
The object
idx
is not used outside the branch, so I think it can be distracting to define it in the "main" body of the function. I believe @IndrajeetPatil has a cite on this being good practice in some contexts too.It would be nice to allow this sort of implicit assignment, defined by the object of assignment is (1) inside
if
and (2) only referenced inside thatif
's parent<expr>
.This argument (let's say
allow_scoped_if_assignment
) would beFALSE
by default since the style guide does not consider this exception.The text was updated successfully, but these errors were encountered: