Is using If, ElseIf, ElseIf better than using If, If, If?
问题 Is there really any difference between using If(this) { } Else If(that) { } Else { } or using, If(this) { } If(that) { } Else { } ? Does one execute any faster? Does the compiler or architecture make any difference? 回答1: There's the huge difference that the contents of the this -block and the that -block can both be executed in the second form, whereas the first form allows at most one of those to be executed. Compare these two Python snippets: x = 10 if x > 5: print "x larger than 5" elif x