On 12/18/2008 10:13 AM, Kenn Konstabel wrote:
Hi,
On Tue, Dec 16, 2008 at 9:13 AM, Wacek Kusnierczyk <
waclaw.marcin.kusnierc...@idi.ntnu.no> wrote:
... but this is also legal if you really hate <- :
foo({x = 2})
# assign to x, pass to foo as a
This is legal but doesn't do what you probably expect -- although
documentation for `<-` says the value (returned by <-) is 'value' i.e.
whatever is on the right side ...
x<-NULL # just to make sure it's not yet 42
foo <- function(a) a
foo({x = 42}) # no result
x
[1] 42
All of x = 42, x <- 42, foo({x = 42}) and foo(x <- 42) do return 42, but
they do it "invisibly", so it won't print. So "no result" isn't quite
right...
Duncan Murdoch
If you really hate <-, you should do either
foo({(x=42)}) # or ....
foo({x=42; x}) # or even ...
foo(a=force(x=43))
As for = being more intuitive, my favorite example is x=x+1 (how on earth
can x equal x+1 ??? ... wait, this is an assignment ¤#§...@{{!!!).
KK
[[alternative HTML version deleted]]
------------------------------------------------------------------------
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.