Re: String to multiple-item list coercion
Re: String to multiple-item list coercion
- Subject: Re: String to multiple-item list coercion
- From: has <email@hidden>
- Date: Fri, 20 Sep 2002 22:56:37 +0100
Steven Angier wrote:
>
I may choose to live under a nice cosy rock, but I just learned that
>
strings can be coerced to multiple-item lists:
>
>
set {a, b, c, d, e} to "abcdefgh"
>
return {a, b, c, d, e}
>
--> {"a", "b", "c", "d", "e"}
This isn't a coercion, it's a multiple assignment. Comparable to:
set {a, b, c, d, e} to {"a", "b", "c", "d", "e", "f", "g", "h"}
>
Similarly, one can now query a particular item of a string:
>
>
item 5 of "abcdefgh"
>
--> "e"
Again, not a new behaviour. Not too dissimilar to 'character 5 of
"abcdefgh"'. Both strings and lists are composite [multi-item] objects.
Think of a string as an array of characters - I think it makes sense for
string and list types to display some behaviours in common. For example,
consider:
repeat with aChar in aString
...
end repeat
>
The ASLG (v1.3.7) indicates that this shouldn't work.
Does it mention it at all? (I could see 'characters of...', etc. described,
but I only had a quick flick-through. Did I miss something specific?)
HTH
has
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
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.