Skip to main content
deleted 14 characters in body
Source Link
Abbas
  • 5.6k
  • 24
  • 40

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } else return false; 

and can even be shortened to simply this, because you're simply returning a boolean corresponding to the equalOk value:

return equalOk; 

Edit:

If I understand your logic, it can be shortened to:

if (c > a && b - a == c - b) { return true; } if (allowEqual) { return (a == b && b <= c) || (a <= b && b == c); } return false; 

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } else return false; 

and can even be shortened to simply this, because you're simply returning a boolean corresponding to the equalOk value:

return equalOk; 

Edit:

If I understand your logic, it can be shortened to:

if (c > a && b - a == c - b) { return true; } if (allowEqual) { return (a == b && b <= c) || (a <= b && b == c); } return false; 

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } return false; 

and can even be shortened to simply this, because you're simply returning a boolean corresponding to the equalOk value:

return equalOk; 

Edit:

If I understand your logic, it can be shortened to:

if (c > a && b - a == c - b) { return true; } if (allowEqual) { return (a == b && b <= c) || (a <= b && b == c); } return false; 
added 270 characters in body
Source Link
Abbas
  • 5.6k
  • 24
  • 40

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } else return false; 

and can even be shortened to simply this, because you're simply returning a boolean corresponding to the equalOk value:

return equalOk; 

Edit:

If I understand your logic, it can be shortened to:

if (c > a && b - a == c - b) { return true; } if (allowEqual) { return (a == b && b <= c) || (a <= b && b == c); } return false; 

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } else return false; 

and can even be shortened to simply this:

return equalOk; 

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } else return false; 

and can even be shortened to simply this, because you're simply returning a boolean corresponding to the equalOk value:

return equalOk; 

Edit:

If I understand your logic, it can be shortened to:

if (c > a && b - a == c - b) { return true; } if (allowEqual) { return (a == b && b <= c) || (a <= b && b == c); } return false; 
deleted 403 characters in body
Source Link
Abbas
  • 5.6k
  • 24
  • 40

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } else return false; 

and can even be shortened to simply this:

return equalOk; 

Alld of the logic can also be simplified. If equalOk is false, a must me smaller than b and b must be smaller than c. If it is true, it must be smaller or be equal to. This code does the same:

if (equalOk) { return a <= b && b <= c; } return a < b && b < c; 

And in one line (perhaps less readable):

return equalOk ? a <= b && b <= c : a < b && b < c; 

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } else return false; 

and can even be shortened to simply this:

return equalOk; 

Alld of the logic can also be simplified. If equalOk is false, a must me smaller than b and b must be smaller than c. If it is true, it must be smaller or be equal to. This code does the same:

if (equalOk) { return a <= b && b <= c; } return a < b && b < c; 

And in one line (perhaps less readable):

return equalOk ? a <= b && b <= c : a < b && b < c; 

I don't know if it is for testing purposes but you shouldn't write ouput tot the console in the method itself.


if (equalOk == true) 

The comparison is redundant as equalOk is a bool which can only be true or false. Thus, this can be rewritten as:

if (equalOk) 

In following code, the else statement is also redundant. If the previous check succeeds, the return will be called and the else will never execute. If it fails, the second return will be called, no need for an else statement.

if (equalOk == true) { return true; } else return false; 

becomes:

if (equalOk == true) { return true; } else return false; 

and can even be shortened to simply this:

return equalOk; 

Source Link
Abbas
  • 5.6k
  • 24
  • 40
Loading