language agnostic - Whats wrong with these beginner style codes? -


I am starting and I was reading. I could not find some things.

1. Why write something like this?

  if (ismaman == true) {console.lightline ("this is a man, man!"); }  

2. What's this about?

  If (test) {back true; } Other {return false; }  

I do not write the code as above, it should be written as: return exam ? Or do I sometimes write it like a return test for readability? True: incorrect or returns (test == true)? True: false

In this example:

  If (IsAManMan == true) {Console.WriteLine ("This is a man, man!"); }  

In most languages, if positions always evaluate Boolean expression, which means IsAManMan is only true or false It may be unnecessary to compare true or false because it is vested so we write it instead:

  if (Islam) {Console.WriteLine ( "This is a man, man!"); }  

and in this example:

  if (test) {back true; } Other {return false; }  

After the above example, it means test can only be either true or false, which is like saying:

  if (true) {return true; } Else {// If this is not true, then this false return is false; }  

This is again the unnecessary dictionary code, so we just

return exam;

Instead

Finally, it is still a matter of priority and readability. For example, if you think that is easier than if (IsAManMan == true) to , then (nominal) , you can still write it and Do not mind the compiler


Comments