Tip: Use Ctrl+W to select content in the IDE code editor.

Tip: Use Ctrl+W to select content in the IDE code editor.

Place your cursor some random piece of code, preferably deep in code that have nested blocks. Press Ctrl+W. Repeat, and repeat while watching the goodness progress.

This tidbit was shared by Jim Mack in a comment in the FB Delphi group.

Edit: The feature was introduced in Berlin 10.1

The feature struggles with Unicode characters in code and strings.

Those of you that use national characters in your strings or code (such as Cyrillic, Greek, or Chinese) that also misbehaves, should add a comment / example to the QP issue and vote on it.

https://quality.embarcadero.com/browse/RSP-19787

Hi guys, kami dari Komunitas Penggemar Pemrograman Delphi (KPPDI) mau adakan workshop gratis di jakarta untuk…

Originally shared by Iwan Cahyadi Sugeng

Hi guys, kami dari Komunitas Penggemar Pemrograman Delphi (KPPDI) mau adakan workshop gratis di jakarta untuk memperkenalkan pemanfaatan IoT dengan Delphi. Delphi yang kita gunakan adalah Delphi Starter Edition yang dapat diunduh dan digunakan secara gratis.

Info lebih lanjut silahkan liat brosur di bawah

Segera daftarkan diri anda, karena tempat sangat terbatas

Record helpers can do wonders for code clarity.

Record helpers can do wonders for code clarity.

// Never mind the silly example

TResult = (CompletedOK, PartiallyPerformed, NothingHappened, HorriblyWrong);

function DoSomething:TResult;

begin

Result := PartiallyPerformed;

end;

How do we determine failure vs success?

if not DoSomething = CompletedOK then …?

What about Partially performed and nothing happened?

Enter the helper:

TResultHelper = record helper for TResult

function Failed:Boolean;

function Success:Boolean;

end;

function TResultHelper.Failed: Boolean;

begin

Result := (Self = HorriblyWrong);

end;

function TResultHelper.Success:Boolean;

begin

Result := not Failed;

end;

Now we can write

if DoSomething.Failed then …

Note that you also can enter the murky waters of obfuscation through helpers, but at least the murkiness will be consistent 😛