Language Usage Question
Posted: 18 February 2008, 5:25 AM
Suppose you have a conditional statement like this
If a = 4 and B < 8 I want to do some stuff!
Should it be written:
This, from SysRef, seems to say either is OK:
"Note that the conditional expression is not required to be enclosed in parentheses. Many programmers are accustomed to other languages where they are required and therefore do so out of habit. Others believe that the parentheses improve the readability and use them for that reason. You’re free to adopt whichever practice suits you."
What happens if you write:
This is not an urgent thing with me as I am a long time Pascal programmer and instinctively use method 2.
Any enlightenment will be appreciated.
Vic
If a = 4 and B < 8 I want to do some stuff!
Should it be written:
Code: Select all
method 1.
If a = 4 And B < 8 Then
'some stuff here
End If
or
method 2.
If (a = 4) And (b < 8) Then
'some stuff here
End If
"Note that the conditional expression is not required to be enclosed in parentheses. Many programmers are accustomed to other languages where they are required and therefore do so out of habit. Others believe that the parentheses improve the readability and use them for that reason. You’re free to adopt whichever practice suits you."
What happens if you write:
Code: Select all
method 3.
If (a = 4) And b < 8 Then
'some stuff here
End If
Any enlightenment will be appreciated.
Vic