Re: set x to "0" = (do shell script "...") ???
Re: set x to "0" = (do shell script "...") ???
- Subject: Re: set x to "0" = (do shell script "...") ???
- From: Steve Mills <email@hidden>
- Date: Mon, 24 Jul 2017 20:35:56 +0000 (GMT)
On Jul 24, 2017, at 02:51 PM, Jim Weisbin <email@hidden> wrote:
I was Googling around, looking into ways to use regex in AS, when I came across this page:
In a few places the code snippets there have the construct:
set x to "0" = (do shell script “…”) etc
I have no idea what that does, or why it compiles. What am I missing?
It's easy enough to deconstruct this syntax. First, see what the results of the "do shell script" are.
Then look at what the script is doing: x is being set to the result of the comparison of "0" to the shell script result. So if the result of the shell script is "0", then x will be set to true.
This is why I like using "is" instead of "=" when doing comparisons. It's a lot more readable for anyone coming from languages where "=" is an assignment operator.
Sent from iCloud's ridiculous UI, so, sorry about the formatting
_______________________________________________
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