Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [array] Some other questions

From: antonr::iinet::net::au at: 22-Nov-2003 19:40

Watch out though, each item in chickenfarm is the same chicken object:
> >> chicken: make object! [ > [ tasty: "wings" > [ ] > >> chickenfarm: array/initial 10 chicken > == [ > make object! [ > tasty: "wings" > ] > make object! [ > tasty: "wings" > ] > make object! [ > t... > Andrew J Martin
Try this: chickenfarm/1/tasty: "drumsticks" ; change first object in the block chickenfarm == [ make object! [ tasty: "drumsticks" ] make object! [ tasty: "drumsticks" ] make object! [... Oh no! They have all changed because they are in fact, all the same. same? chickenfarm/1 chickenfarm/2 ;== true I recommend doing this instead: chickenfarm: copy [] ; make a new block loop 10 [append chickenfarm make chicken []] Now they are all cloned from the original chicken. Anton.