jeudi 11 novembre 2021

Do you need an "else" if you don't need an ElseIf? [closed]

This is not specific to any language; it's a general question about "if" statements.

Do you need an "Else" if you don't need an "ElseIf" and the "if" terminates the function? And if it doesn't matter, does one or the other impact the speed of your code? See two examples below, one with an "else" and one without.

If (iValue > 10) Then
    Exit Function
Else
    [....some code] 
End If
End Function

Without "Else":

If (iValue > 10) Then
    Exit Function
End If

    [....some code]
End Function

Aucun commentaire:

Enregistrer un commentaire