Call it walrus operator, closes #1591

This commit is contained in:
Mine Çetinkaya-Rundel 2023-11-09 09:32:17 -05:00
parent 03dbd81dbb
commit fd39b442f4
1 changed files with 1 additions and 1 deletions

View File

@ -737,7 +737,7 @@ sorted_bars <- function(df, var) {
diamonds |> sorted_bars(clarity) diamonds |> sorted_bars(clarity)
``` ```
We have to use a new operator here, `:=`, because we are generating the variable name based on user-supplied data. We have to use a new operator here, `:=` (commonly referred to as the "walrus operator"), because we are generating the variable name based on user-supplied data.
Variable names go on the left hand side of `=`, but R's syntax doesn't allow anything to the left of `=` except for a single literal name. Variable names go on the left hand side of `=`, but R's syntax doesn't allow anything to the left of `=` except for a single literal name.
To work around this problem, we use the special operator `:=` which tidy evaluation treats in exactly the same way as `=`. To work around this problem, we use the special operator `:=` which tidy evaluation treats in exactly the same way as `=`.