<div dir="ltr"><div>Every time you redefine it, it is redefined. And depending on implementation the variable could be valid only inside of the loop. If not, then it is what it is defined.</div><div><br></div><div>For idx as integer = 0 to things.max<br>
dosomething(thing[idx])<br>
next</div><div><br></div><div>Above idx is integer.<br></div><div><br>
...<br>
For idx = 0 to others.max<br>
dosomthingelse(others[idx])<br>
next</div><div><br></div><div>Above idx is either undeclared or integer, depending on implementation.<br></div><div><br>
...<br>
For each idx as float in floatarray<br>
dowhatever(idx)</div><div><br></div><div>Above idx is float.</div><div><br></div><div><br></div><div>Jussi<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 12, 2018 at 1:31 AM Bruce <<a href="mailto:adamnt42@gmail.com">adamnt42@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Well, I haven't tried it yet but a few things pop into my mind.<br>
<br>
Consider a method that has lots of use of "throw away" indexers/iterators,<br>
For idx as integer = 0 to things.max<br>
dosomething(thing[idx])<br>
next<br>
...<br>
For idx = 0 to others.max<br>
dosomthingelse(others[idx])<br>
next<br>
...<br>
For each idx as float in floatarray<br>
dowhatever(idx)<br>
<br>
etc<br>
Is it going to redefine idx each time?<br>
<br>
b<br>
<br>
On 12/12/18 9:46 am, Benoît Minisini wrote:<br>
> Le 12/12/2018 à 00:11, Jussi Lahtinen a écrit :<br>
>> Why would it be harder to debug?<br>
>> David gave great example of it usage (pretty much only case where I <br>
>> use it) and I think it only makes code more readable and less scope <br>
>> for the variable.<br>
>><br>
>><br>
>> Jussi<br>
>><br>
> <br>
> Because as soon as variables can be declared anywhere, people will start <br>
> to use that for writing ugly code. :-)<br>
> <br>
<br>
----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
</blockquote></div>