Re: list question
Re: list question
- Subject: Re: list question
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 03 Jun 2003 20:35:23 -0700
On 6/3/03 7:18 PM, "Michelle Steiner" <email@hidden> wrote:
>
On Tuesday, June 3, 2003, at 07:03 PM, Chris Page wrote:
>
>
> What you did was bind the variable 'a' to a new string created by
>
> concatenating "A" -- the string 'a' was initially bound to -- and "B".
>
>
>
> set a to "A"
>
> set original_a to a
>
> set a to a & "B"
>
> {a, original_a}
>
> --> {"AB", "A"}
>
>
>
> What you're seeing is 'a' being bound to a new value. Nothing is being
>
> mutated.
>
>
Well, to the scripter and especially to the user, it appears that the
>
variable a is being changed (mutable means changeable) from "A" to "AB".
If a string were mutable, you would be able to do:
set character 4 of "mutable" to "i"
But you can't, because strings aren't mutable. You have to make a new
instance with the altered string. Changing the assignment (re-binding) of a
variable representing a string is a totally different matter:
set var to "mutable"
set character 4 of var to "i" --> ERROR
set item 4 of var to "i" --> ERROR
set var to "mutible" --> reassignment: no problem
Whereas:
set chars to characters of "mutable"--> {"m", "u", "t", "a", "b","l",
"e"}
set item i of chars to "i" --> no problem, lists are mutable
chars --> {"m", "u", "t", "i", "b","l", "e"}
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.