Check if a variable exists

Peter Thomassen info at peter-thomassen.de
Mon Aug 21 15:50:33 PDT 2006


Kirk McDonald schrieb am Samstag, 19. August 2006 01:07:
>>>Oh. Then you don't want this at all. Use the bool. :-) The reason is
>>>simple: if you declare the temporary before the for loop, then it will
>>>always exist after the for loop. If you declare the temporary inside the
>>>for loop, then it only has the scope of the for loop; it will cease to
>>>exist when the loop ends. Whichever way you do it, whether it exists or
>>>not after the for loop never varies.
>> 
>> This is not true, I tested it (using a while, not a for).
> 
> Hmm?
> 
> [...]
> 
> $ dmd test
> test.d(9): undefined identifier j
> 
> Seems to be true to me.

Yeah ... I think I can remember a case where this was not true, but probably
I haven't noticed a declaration some lines before the loop.

Sorry,
Peter



More information about the Digitalmars-d-learn mailing list