Re: set vs copy?
Re: set vs copy?
- Subject: Re: set vs copy?
- From: Alex Zavatone <email@hidden>
- Date: Wed, 15 Sep 2010 01:55:53 -0500
it never gets its own value. B points the values in A. This is because a list is the variable value.
On Sep 15, 2010, at 1:51 AM, Thomas Fischer wrote:
> Hi Mark,
>
> I still don't understand when the second variable get its on value.
> I agree that your example shows nicely that A and B point to the same variable.
> But
>
> set A to {1, 2, 3}
> set B to A
> copy A to C
> set A to {6, 7, 8}
> set text item delimiters to ","
> log ("A is " & A as text)
> log ("B is " & B as text)
> log ("C is " & C as text)
>
> yields
>
> (*A is 6,7,8*)
> (*B is 1,2,3*)
> (*C is 1,2,3*)
>
> Why that?
>
> Cheers
> Thomas
>
>
> Am 15.09.2010 um 01:51 schrieb Mark J. Reed:
>
>> set A to {1,2,3}
>> set B to A
>> copy A to C
>>
>> set end of A to 4
>> set end of B to 5
>>
>> set text item delimiters to ","
>> log("A is " & A as text)
>> log("B is " & B as text)
>> log("C is " & C as text)
>>
>> Result:
>>
>> A is 1,2,3,4,5
>> B is 1,2,3,4,5
>> C is 1,2,3
>>
>>
>> A and B are both pointing to a single list; changing that list,
>> whether you go through A or B, results in a change visible through
>> both. C is a separate copy of that list made when it only had 3
>> elements, unaffected by subsequent modifications to the original. You
>> can, of course, now go and modify C, and it won't affect A or B.
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> AppleScript-Users mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> Archives: http://lists.apple.com/archives/applescript-users
>>
>> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden