On 2 dec 2012, at 08:09, Shane Stanley < email@hidden> wrote: On 02/12/2012, at 1:10 PM, Shane Stanley <email@hidden> wrote:
I guess to be a fair comparison on both counts you should probably tack on "as boolean" -- although I suspect the effect will be negligible.
Wake up! Of course you don't have to do any such thing...
In this particular case, I knew that fileExistsAtPath_ returned an AS boolean into flag (because I had tested my code, and I wanted it to be minimal). But I do admit that I do not know the rules when such coercion is automatic. NSFileManager methods that return BOOL seem to always return booleans into AS, despite BOOL is specified internally as type char. For NSString this is not so, but one can "cheat" by omitting the parentheses on parameterless methods:
set myString to current application's NSString's stringWithString_("/usr") myString's isEqualToString_("/usr") --> 1 myString's hasPrefix_("/") --> 1 myString's isAbsolutePath() --> 1 myString's isAbsolutePath --> true myString's boolValue() --> 0 myString's boolValue --> false
Although explicit coercion to boolean is safest, I am curious to learn the rules, and why e.g NSFileManager does not need coercion.
--heb |