[fpc-pascal] methods of an object to create others objects

Marcos Douglas md at delfire.net
Tue Jul 6 20:11:00 CEST 2010


On Tue, Jul 6, 2010 at 12:56 PM, Luiz Americo Pereira Camara
<luizmed at oi.com.br> wrote:
> Marcos Douglas escreveu:
>>
>> Better:
>>
>> obj1 := nil;
>> obj2 := nil;
>> Try
>>  obj1 := TMyObject.Create;
>>  obj2 := TMyObject.Create;
>>
>>  obj1.DoSomething1;
>>  obj2.DoSomething2;
>> finally
>>  obj1.Free;
>>  obj2.Free;
>> end;
>>
>> The objectcs are protected. But is boring... :)
>> Everybody codify like that, afraid if resources are not available?
>
> An article from today:
> http://www.monien.net/blog/index.php/2010/07/creating-multiple-objects-using-try-finally/

Ok!
Well... sincerely I only use this method when I not know if an object
will be instanced or not (depends of algorithm).


Marcos Douglas



More information about the fpc-pascal mailing list