Why is := allowed as an infix operator?

后端 未结 2 520
一整个雨季
一整个雨季 2020-12-03 16:47

I have come across the popular data.table package and one thing in particular intrigued me. It has an in-place assignment operator

:=

2条回答
  •  误落风尘
    2020-12-03 17:32

    It's not just a colon operator but rather := is a single operator formed by the colon and equal sign (just as the combination of "<" and "-" forms the assignment operator in base R). The := operator is an infix function that is defined to be part of the evaluation of the "j" argument inside the [.data.table function. It creates or assigns a value to a column designated by its LHS argument using the result of evaluating its RHS.

提交回复
热议问题