Re: Things I thought I knew, but didn't - variable scope in repeat loops
Re: Things I thought I knew, but didn't - variable scope in repeat loops
- Subject: Re: Things I thought I knew, but didn't - variable scope in repeat loops
- From: "Mark J. Reed" <email@hidden>
- Date: Sat, 27 Dec 2008 09:53:33 -0500
On Sat, Dec 27, 2008 at 4:39 AM, Richard Rönnbäck
<email@hidden> wrote:
> It turns out that my old habit of using unique loop variables is sound after
> all, as this example shows:
Absolutely. Always a good practice to use different names for
different variables. More descriptive names help make that sort of
happen automatically. But as Ed pointed out, if for some reason you
want to confuse someone reading your code, you can have a loop counter
(local variable) with the same name as a global variable or property:
> set i to "hi, mom!"
>
> repeat with i from 1 to 10
> say i
> end repeat
>
> say i
property i: "hi, mom!"
repeat with i from 1 to 10
say i
end repeat
say i
--
Mark J. Reed <email@hidden>
_______________________________________________
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