Skip to content

Instantly share code, notes, and snippets.

@Groxx
Created February 22, 2010 18:47
Show Gist options
  • Save Groxx/311342 to your computer and use it in GitHub Desktop.
Save Groxx/311342 to your computer and use it in GitHub Desktop.
Serious weirdness in AppleScript with the "contents" property.
tell application "AppleScript Editor"
set d to document 1
set str to "set d to document 1 of AppleScript Editor, and watch the shenanigans.
"
set str to str & ("d is equal to d == " & (d is equal to d) as text) & "
"
set str to (str & "d is equal to (contents of d) == " & (d is equal to (contents of d)) as text) & "
"
set str to str & "d is equal to (contents of (contents of d)) == " & (d is equal to (contents of (contents of d))) as text
set str to str & "
"
set str to str & "Setting d = contents of d...
"
set str to str & ("d is equal to d == " & (d is equal to d) as text) & "
"
set str to (str & "d is equal to (contents of d) == " & (d is equal to (contents of d)) as text) & "
"
set str to str & "d is equal to (contents of (contents of d)) == " & (d is equal to (contents of (contents of d))) as text
set str to str & "
WTF Apple? Identity function much?"
display dialog str
(* results:
"set d to document 1 of AppleScript Editor, and watch the shenanigans.
d is equal to d == true
d is equal to (contents of d) == true
d is equal to (contents of (contents of d)) == false
Setting d = contents of d...
d is equal to d == true
d is equal to (contents of d) == true
d is equal to (contents of (contents of d)) == false
WTF Apple? Identity function much?"
*)
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment