Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Assignment (<- not =) #237

Open
jaaan-t opened this issue Dec 2, 2024 · 2 comments
Open

Assignment (<- not =) #237

jaaan-t opened this issue Dec 2, 2024 · 2 comments

Comments

@jaaan-t
Copy link

jaaan-t commented Dec 2, 2024

In style/syntax.qmd under Assignment it says: Use <-, not =, for assignment.

Why, though? An explanation would be helpful, especially for newcomers. <- seems unnecessary bordering on obtuse to people coming from other languages, so giving them a good explanation might help to enforce this suggestion.

@IndrajeetPatil
Copy link

Others will probably chime in, but here is one reference to support this rule:

cf. https://www.burns-stat.com/pages/Tutor/R_inferno.pdf#page=94.19

Image

@MichaelChirico
Copy link
Collaborator

Worth noting that the style guide also discourages implicit assignment:

style/syntax.qmd

Lines 283 to 286 in 315943b

# Bad
if (nzchar(x <- complicated_function()) < 1) {
# do something
}

So the above example already violates the guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants