Displaying 1 result from an estimated 1 matches for "fight2".
Did you mean:
fight
2011 Dec 06
1
making changes to global variables in functions
...stateA and stateB into a single
object, I could return it and then assign it back to objects state1 and
state2. Or if I could pass a pointer to the original object.. But I cannot
find an easy way of doing either. Thanks in advance..
state1 <- list(n=100, won=0)
state2 <- list(n=100, won=0)
fight2 <- function(stateA, stateB){
stateA$n <- 50
stateB$n <-50
}
fight2(state1,state2)
state1$n
state2$n
[[alternative HTML version deleted]]