Re: list of records
Re: list of records
- Subject: Re: list of records
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 11 Dec 2000 16:45:22 -0800
On 12/11/00 1:14 PM, "Frank Watzl" <email@hidden> wrote:
>
set r to {FileType:"LINK", CreatorType:"MSIE"} -->record
>
set L to {{FileType:"LINK", CreatorType:"MSIE"}, "foo", {FileType:"PICT",
>
CreatorType:"8BIM"}} --> 3 item list
>
r is in L -->false **why not true?
>
r = item 1 of L -->true **aah!
>
>
Any Ideas why in the 3rd line the result is false?
{r} is in L -->true
The class of the item contained must be the same as the container in any
expression using 'contains' or its converse 'is in': list, record or string
on both sides of the "contains, "is contained by" ("is in") operator. L is
a list, but r is a record, so you must express r as a one-item list {r}
Most of the time we neglect this without problem, because we are looking for
a string in a list of strings:
set s to "a"
set L to {"a", "b", "c"}
s is in L --> true
but that's because AppleScript generously coerces a 'single item' (string or
number) to a single-item list
s is in L --> coerced to
{s} is in L --> true
But it can't do that with a record.
See the ASLG pp 227-9.
--
Paul Berkowitz