# Unreachable Code

##### Tags:

- C/AL

##### Categories:

- Best Practice

Do not write code that will never be hit.

It affects code readability and can lead to wrong assumptions.

Bad code

    IF Type <> Type::FIELD THEN BEGIN
        ...
        ERROR(...);
        RecRef.CLOSE;
    END;

Good code

    IF Type <> Type::FIELD THEN BEGIN
        ...
        RecRef.CLOSE;
        ERROR(...);
    END;

Last modified February 24, 2022: Added tags & categories + cleanup (5ee04366) by waldo1001