Skip to content
Prev 165135 / 398503 Next

Is = now the same as <- in assigning values

Kenn Konstabel wrote:
if you think the use of force guarantees that x is assigned 43, you're
wrong.

foo = function(a) 0
x = 1
foo(a=force(x=2))
x

foo = function(a) deparse(substitute(a))
x = 1
foo(a=force(x=2))
x

in both cases, the result (the final value of x, but not the value
returned by foo in the second example) does not change when you replace
'force(x=2)' with 'x<-2'.

vQ