Hello I’m wondering why some people write if statement the following way.
IF Record."Some Boolean field" = TRUE then begin
end;
IF Record."Some Boolean field" then begin
end;
Which one is easier to read? The second one is probably some millisecond faster or maybe the compiler is smart enough to remove the unnecessary " = TRUE" part.
Thanks.
Comments
RIS Plus, LLC
And I also like the parentheses especially when there are multiple conditions in the if statement.
Using the standard way makes it easier for everyone in the community.
It is also mandatory to use for the current CfMD certification for NAV2013...
I do not agree that this is easier for all, because to me, the first way of writing the code is easier to read. Overall I agree that adhering to a standard makes things easier, but to me that applies to naming conventions more than whether you use literal values in expressions, or whether you use BEGIN and END for single line statements.
It might be mandatory, but I seriously doubt that there is a team of people that actually checks each line of code to make sure you don't evaluate boolean types against literal values.
RIS Plus, LLC
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.