Coercion of string to a record label
Coercion of string to a record label
- Subject: Coercion of string to a record label
- From: Olof Hellman <email@hidden>
- Date: Tue, 09 Oct 2001 10:11:45 -0700
Ah, my favorite topic. From a suggestion of mine, cleaned up by Emmanuel:
to usrf(theList)
script
{+class usrf;:theList}
end script
run script the result
end usrf
usrf({"a", 1, "b", 2})
--> {a:1, b:2}
The only problem is, due to canonicalization of AppleScript user record
field tags, everything in the tag string must be lower case. If not, you
need to use the bars to make it work:
usrf({"three word tag", 1, "UPPERCASE", 2})
--> {|three word tag|:1, |UPPERCASE|:2}
- Olof
n.b. As usual, the chevrons will get mangled by the listserv: the
characters around
+class usrf;
are the left-pointing and right-pointing chevrons, option backslash + and
shift option backslash ; .