Conflicting statement
Closed this issue · 1 comments
alpinistbg commented
Here, at the end of line 943:
... This dirty trick works only in non-virtual methods (that don't call any virtual methods and don't access any fields).
But actually TObject.Free calls TObject.Destroy which is in turn virtual.
michaliskambi commented
Thank you!
Indeed the clause "(that don't call any virtual methods and don't access any fields)" was confusing. It was meant to mean "you cannot call any virtual methods / access fields if Self is (possibly) nil".
I improved the text, also added an example showing it in https://github.com/michaliskambi/modern-pascal-introduction/blob/master/code-samples/method_with_self_nil.lpr . As expected, it works with non-virtual method, but crashes with virtual.
