Is = now the same as <- in assigning values
Wacek Kusnierczyk wrote:
Kenn Konstabel wrote:
Hi,
On Tue, Dec 16, 2008 at 9:13 AM, Wacek Kusnierczyk <
Waclaw.Marcin.Kusnierczyk at 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 ...
as far as i can see, this does precisely what i expect -- it assigns 2 to x and then passes x as the argument a to foo. did you mean there is something else happening here?
too quick this time: the 'then' is not appropriate, as it is an expression, not its value, that is passed to foo. so this does what i expect, and what i'd expect with x <- 2 instead, namely: x is assigned 2 on the first occasion the argument a is used within foo, and effectively a has the value of x after the assignment. vQ