Re: Deleting last item of a List
Re: Deleting last item of a List
- Subject: Re: Deleting last item of a List
- From: Nigel Garvey <email@hidden>
- Date: Sat, 20 Nov 2004 13:47:21 +0000
kai wrote on Sat, 20 Nov 2004 01:28:03 +0000:
>Later, on Fri, 19 Nov 2004 23:07:46 +0000, Nigel then wrote:
>
>> My rough guess for why getting the end of a list is faster than
>> getting its last item is that AppleScript doesn't need to check that
>> the last item is actually an 'item'. :-) Rather in the same way that
>> counting a list is faster than counting its items.
>
>That would be about my take on it too, Nigel.
>
>If one takes a single object (such as a string) that is not itemised as
>a list, then 'end' will produce an error number -1728
>(errAENoSuchObject) [1] - suggesting that AppleScript has not checked
>for items:
>
>------------------------
>
>set myString to "abc"
>end of myString
>--> error: Can't get end of "abc".
>
>------------------------
I had a look in the AppleScript Language Guide this morning. It says:
[quote]
beginning | front
end | back
The beginning and front forms are equivalent and refer to the first
insertion point of the container (insertion point 1). The end and back
forms are equivalent and refer to the last insertion point of the
container (insertion point -1).
Although terms such as beginning and end sound like absolute positions,
they are relative to the existing contents of a container (that is,
before or after the existing contents).
[/quote]
The assertions of equivalence are wrong - at least, with regard to
AppleScript Language lists. "Front" and "back" can only be used
adjectivally and are equivalent to "first" and "last" respectively.
The "insertion point" idea is helpful though. Items can be inserted at
two points in a list: the beginning and the end. Strings don't have any
insertion points, so referring to one of them would cause an error. ;-)
Presumably, with a list, it's quicker to locate the element at or next to
the 'end' insertion point than it is to identify the last of the list's
"items".
NG
_______________________________________________
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