Re: Adding To A List
Re: Adding To A List
- Subject: Re: Adding To A List
- From: has <email@hidden>
- Date: Thu, 2 Jun 2005 10:41:40 +0100
DigitEL wrote:
>Can anyone suggest why the following code which I am trying to create
>a list of incremented lists returns a list with all of the contained
>lists equal to the last list incremented?
Because all your sub-lists are the same object. You want to create a new list object each time, so change the last line to either:
set the end of the newList to (items of currentList) -- shallow-copy the list
or:
copy currentList to the end of the newList -- deep-copy the list
(Note: in this case it doesn't matter if you shallow- or deep-copy the list so either will do here; it's only an issue when copying a list containing other mutable objects, depending on whether or not you want to duplicate those as well.)
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden