Search the Community
Showing results for tags 'capture'.
Found 1 result
Code that looks correct, and appear to compile alright, but which doesn't execute well. Can you spot the error? See my blog post for a link to a SCCE. var Handler: THandlerClass; hType: THandlers; begin Broker.Clear; for hType in [foo, bar] do begin case hType of foo: Handler := TFoo.Create; bar: Handler := TBar.Create; end; Broker.AddHandler(Handler.OnHandle); end; end; https://larsfosdal.blog/2019/02/08/delphi-pitfalls-of-anonymous-methods-and-capture/