I am trying to come to grips with using with statements in delphi properly.
Overall it seems fairly simple to do simple things with but I am interested in finding some good code examples and/or tutorials on using nested with statements. E.G.
with object1, object2, etc... do
begin
statements
end;
What I am unsure of is the order of precedence when using with statements in such a manner.
Any advice is appreciated.
The best advice I can give you is:
Do not use with ever.
If you feel like using ‘with’, go and lie down until the feeling passes.
If you feel like using a nested with, pound your hand with a hammer until the desire goes away.
‘with’ is just a bug waiting to happen. Altering classes used with it can alter the meaning of your code. It creates imprecise semantics, and that is always bad.
Saving keystrokes is never a good reason to use ‘with’. A few more keystrokes now will save you a lot of pain later.
‘With’ should be shunned.