Why does the following work in R?
> `:=` <- function(x, y) x + y
> 1 := 2
[1] 3
My understanding was that % was required for user-defined infix operators. Are there other (possibly easier to type) options available?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is because
:=is, like<-or<<-, defined asLEFT_ASSIGNfor the parser of R.See http://svn.r-project.org/R/trunk/src/main/gram.y
This means that
:=is a special case and you may as well not expect that any other options are available.