not quite sure why but I do this a lot too, especially Reset() on every record variable. I know locals are supposed to be initialized at the procedure level but I've seen it go wrong too many times and got into the habit of doing that I suppose
Comments
Log in with your Bluesky account to leave a comment
Wait what? π€― I never do a Reset() on a local (record) variable, where I always thought this isnβt necessary for a local variable. Can you shine some light on what possibly can go wrong? π€
It's probably one of those things where I worked on a bug and nothing worked, and adding the reset seemed to have solved it. One of those things that I do because I believe that it worked that one time
It's really a bad habit though. Scope matters, I should stop doing it :)
Itβs really a remnant based in paranoia from so many buggy debuggers in older versions. The tools are really good now, I should probably let go of some of those habits. Iβm going to work on that, this is a really good conversation for me :)
I could automate that for your with the LC? π€ If itβs a local variable and this first line within the method is doing a Clear/Reset, then show a diagnostic on it?
I currently do that for code fields since there is warning from the AL Language when you use a variable that wasn't set .
Common pattern: Save the last No in a loop and compare on this value .
Comments
It's really a bad habit though. Scope matters, I should stop doing it :)
Common pattern: Save the last No in a loop and compare on this value .
https://github.com/microsoft/AL/issues/7440