• 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: how to compare two lists without looping? Possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to compare two lists without looping? Possible?


  • Subject: Re: how to compare two lists without looping? Possible?
  • From: Stan Cleveland <email@hidden>
  • Date: Fri, 10 Feb 2006 14:59:33 -0800
  • Thread-topic: how to compare two lists without looping? Possible?

On 2/10/06 11:04 AM, email@hidden wrote:

> BTW, what means 'duck typed'?

Ruby programmers take advantage of the fact that different data types can
behave similarly. In Ruby parlance, if an object "looks like a duck and
sounds like a duck," then treat it as though it were a duck. This can be
illustrated in AppleScript by the following examples:
    9 + 3.0  --> 12
    9 + "3"  --> 12
    9 + {3}  --> 12
In all cases, the "three" gets treated as an integer, even though the actual
objects are a real, a string, and a one-element list. Since they all "look
and sound" like an integer, why not allow any or all as valid integers where
it suits the situation? (A search for "duck typing" will turn up many web
pages on the topic.)

There are caveats to beware of when using this technique. Check out the
section called "Implicit Coercion" in Matt Neuberg's book "AppleScript, The
Definitive Guide" starting on page 244 in the 2nd edition, 264 in the 1st.
(Other AppleScript books in my library discuss this type of coercion, but
none as thoroughly as Matt's.)

Stan Cleveland
Color Technology Inc.
Portland, Oregon

"If recursion quacks like a loop, then it must be a loop."


 _______________________________________________
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

  • Prev by Date: Re: File exists on a posix path
  • Next by Date: Re: Dealing with Sliders...
  • Previous by thread: Re: how to compare two lists without looping? Possible?
  • Next by thread: How to escape paragraph return and enter to InDesign
  • Index(es):
    • Date
    • Thread