• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Coerce string to string!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coerce string to string!?


  • Subject: Re: Coerce string to string!?
  • From: has <email@hidden>
  • Date: Thu, 14 Feb 2002 14:14:48 +0000

Paul Berkowitz wrote:

>> class of i
>> --> string (OK)
>
>That evaluates 'item 1 of {"String"}' to "String" before it gets its class.

[and]

> i is a reference ('item 1 of {"String"}'), whereas Original_String is
>the string "String" itself. Not the same thing. The equals operator '=' is
>extremely particular about such things, whereas other operators such as
>'contains' are happy to evaluate the reference as they go along.

i.e. It does one thing in one case and something else in another,
confounding user expectations every time. (Is there anyone who hasn't been
horribly confused by this one at some point?) References are so damn
schizophrenic in behaviour- definitely not AppleScript's finest moment.


>Because 'i' is NOT a string, it's a reference to a string. You can either do
>the coercion, as above, or use the other type of repeat loopwhich always
>does the dereferencing for you:

You can also use:

contents of i

to resolve the reference for you. As in:

repeat with i in {1, 2}
display dialog (contents of i = 2) as string
end repeat

HTH

has
_______________________________________________
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.

  • Follow-Ups:
    • Re: Coerce string to string!?
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: script object property contamination
  • Next by Date: Newbie Set eof to 0
  • Previous by thread: Re: Coerce string to string!?
  • Next by thread: Re: Coerce string to string!?
  • Index(es):
    • Date
    • Thread