Skip to content
Prev 157327 / 398506 Next

Return a list

Bert Gunter wrote:
it depends on what the original author wanted.

with constructs a new environment, and all assignments, if any, made in
the expression evaluated within with are invisible to the outside
(unless one plays with environments, again):

x = 1:10
a = 3
with(test(), { x[1:3] = c(a,b,c); x = x+d; a = a + 1 })
x # still 1:10, whatever test returns
a # still 3. whatever test returns

if the author wanted the values included in the list to be visible and
accessible by simple names, and used in assignments in a larger part of
code, using with might be inconvenient.
it does not mean that my solution below is a good one, it's just a quick
fix.  i wouldn't do that in myself, it's badly non-functional ;)

vQ