On 29 Apr 2014, at 10:29 am, Stan Cleveland < email@hidden> wrote: On Apr 28, 2014, at 4:04 PM, Shane Stanley wrote: set volumeChoice to (choose from list namesArray with prompt "Choose a volume to mount.") … set volumeChoice to item 1 of volumeChoice
Hi all,
I've always been one for clarity, first, and efficiency, second, in my AS coding. To that end, I'd like to suggest a further simplification of the code that Shane posted a bit ago.
The two lines quoted above can be replaced by this one line:
set {volumeChoice} to (choose from list namesArray with prompt "Choose a volume to mount.")
For each pair of braces added around a variable name when it's defined, one pair is removed from its definition. There's no need to "unbrace" volumeChoice with a separate line of code.
Here's another silly, but clear, example of this technique:
set nestedList to {{{{"Hello, world"}}}} set {{{{greeting}}}} to nestedList return greeting --> "Hello, world"
Regards, Stan C.
Hi Stan,
This will fail if the user selects ‘Cancel’ Which is something that Shane’s code was handling.
Also, I see your point with your example, but I think you’re still making it a little confusing, I think a clearer sample for a new user would be something like
set {firstName, lastName} to {"wayne", "melrose"}
return firstName |