Re: Set Multiple variables to one value
Re: Set Multiple variables to one value
- Subject: Re: Set Multiple variables to one value
- From: has <email@hidden>
- Date: Thu, 1 Aug 2002 00:13:12 +0100
Paul Berkowitz wrote:
>
> Is it possible to set multiple variables to one value in one swoop?
>
>
>
> Instead of:
>
>
>
> set var1 to 30
>
> set var2 to 30
>
> set var3 to 30
>
> set var4 to 30
>
> set var5 to 30
>
>
>
> Is there a way of simplifying it down into something like "set every item in
>
> {var1, var2, var3, var4, var5} to 30"
>
>
set {var1, var2, var3, var4, var5} to {30, 30, 30, 30, 30}
I think maybe Stephen was meaning something along the lines of:
var1 = var2 = var3 = var4 = var5 = 30
which some languages will let you do, but AS [preferring simplicity over
terseness] doesn't.
Personally, I wouldn't recommend using multiple assignment except in
circumstances where you actually mean to perform a simultaneous assignment
of values, eg:
set {foo, bar} to {bar, foo}
It doesn't make code any more readable [indeed, it may well make it harder
to read], plus there's a performance penalty which can be an issue in
performance-critical code. Where in doubt, KISS.
HTH
has
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.