Is there any real difference between these two methods?
Method 1:
bool IsNumOverFive(int num)
{
if(num > 5)
{
return true;
}
else
{
return false;
}
}
Method 2:
bool IsNumOverFive(int num)
{
if(num > 5)
{
return true;
}
return false;
}
As far as the computer is concerned, there is no difference between the two versions.
Given that both are correct, what’s important is that whoever is reading the code finds it easy to read.
I happen to prefer a third version:
Others may have different preferences.