I am still relatively new to the world of coding, but I was wondering if there is an advantage to Nathan typing return after an if statement instead of putting the code in the if statement. An example of this is in the select method of Unit, he says:
public void Select()
{
if (!hasAuthority) return;
onSelected?.Invoke();
}
If I were to do it on my own, I would’ve said:
public void Select()
{
if (hasAuthority)
{
onSelected?.Invoke();
}
}
Is there an advantage or is it just his coding style?