Skip to content

Commit 073af4a

Browse files
Discuss the difference in precedence for the : operator between R and Julia. (#41681)
1 parent 4f77aba commit 073af4a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

doc/src/manual/noteworthy-differences.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ For users coming to Julia from R, these are some noteworthy differences:
163163
* In Julia, a range like `a:b` is not shorthand for a vector like in R, but is a specialized `AbstractRange`
164164
object that is used for iteration. To convert a range into a vector, use
165165
[`collect(a:b)`](@ref).
166+
* The `:` operator has a different precedence in R and Julia. In particular, in Julia arithmetic operators
167+
have higher precedence than the `:` operator, whereas the reverse is true in R. For example, `1:n-1` in
168+
Julia is equivalent to `1:(n-1)` in R.
166169
* Julia's [`max`](@ref) and [`min`](@ref) are the equivalent of `pmax` and `pmin` respectively
167170
in R, but both arguments need to have the same dimensions. While [`maximum`](@ref) and [`minimum`](@ref)
168171
replace `max` and `min` in R, there are important differences.

0 commit comments

Comments
 (0)