开发者

Why does `:=` work as an infix operator?

Why does the following work in R?

> `:=` <- function(x, y) x + y
> 1 := 2
[1] 3

My understanding was that % was required for user开发者_如何学Python-defined infix operators. Are there other (possibly easier to type) options available?


This is because := is, like <- or <<-, defined as LEFT_ASSIGN for 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜