Why does b have a value?

老子叫甜甜 提交于 2021-01-29 06:45:10

问题


Why does b have a value? I think b should be null, because there is no return in function f.

f <- function(){
  a <- 10
}

b <- f()

b
# [1] 10

回答1:


<- operator returns assignement invisibly, which allows

b <- a <- 1
b
a

> b
[1] 1
> a
[1] 1


来源:https://stackoverflow.com/questions/63950864/why-does-b-have-a-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!