• 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: Checking on the existence of a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking on the existence of a file


  • Subject: Re: Checking on the existence of a file
  • From: Harald E Brandt <email@hidden>
  • Date: Tue, 04 Dec 2012 10:14:10 +0100


On 3 dec 2012, at 23:16, Shane Stanley <email@hidden> wrote:

... yet one returns a boolean and the other an integer. Mysterious.

Indeed!

And if you call one AS class from another, you get NSNumbers rather than boolean/integer/real.

Likewise, the omission of parentheses on those parameterless methods will also yield NSNumbers, or to be more precise: __NSCFNumber.
set myString to current application's NSString's stringWithString_("/usr")
myString's isAbsolutePath --> true (omission of parentheses, otherwise it becomes an integer)
myString's isAbsolutePath's className() --> __NSCFNumber
myString's isAbsolutePath()'s className() --> error (since it's not an object)
class of myString's isAbsolutePath --> __NSCFNumber
class of myString's isAbsolutePath() --> integer

On numerous occasions, I have forgotten those parentheses without being warned about it, because it works anyway, and when I add the parentheses, then coercion suddenly becomes necessary. I actually think that it would have been much better to not even allow omission of those parentheses, since you never know what a future version of OS X might do with that syntax.

--heb
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Checking on the existence of a file
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Checking on the existence of a file (From: Harald E Brandt <email@hidden>)
 >Re: Checking on the existence of a file (From: Shane Stanley <email@hidden>)
 >Re: Checking on the existence of a file (From: Shane Stanley <email@hidden>)
 >Re: Checking on the existence of a file (From: Harald E Brandt <email@hidden>)
 >Re: Checking on the existence of a file (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Nearly complete
  • Next by Date: Re: Checking on the existence of a file
  • Previous by thread: Re: Checking on the existence of a file
  • Next by thread: Re: Checking on the existence of a file
  • Index(es):
    • Date
    • Thread