M
MaXiaochi
In most of the case,there is a "break" after every "case" in switch
statement, poor coders have to write "break" explicitly again and
again,and the worse is that sometimes someone forget to do that.So why
don't the designers make it a default state? if sometimes someone
prefer his switch statement without a break,he can achieve it by
duplicating code for once.
In fact,I appreciate the counterpart "DO CASE ... ENDCASE" in
VFP,which takes not only equality but also other boolean expressions at
every case.If the expression is true, the coomands just after this case
excutes,ignoring other case,no matter they are true or not.I think it
much more convenient.
For example,to classify people by age,you code like this:
DO CASE
CASE age<3
kind=baby
CASE age<14
kind=child
CASE age<18
kind=adolescent
OTHERWISE
kind=adult
As to Java,the best way to achieve it is to use "if-else",only if we
divide people by 5,10,15,20, the "switch" is useful.
statement, poor coders have to write "break" explicitly again and
again,and the worse is that sometimes someone forget to do that.So why
don't the designers make it a default state? if sometimes someone
prefer his switch statement without a break,he can achieve it by
duplicating code for once.
In fact,I appreciate the counterpart "DO CASE ... ENDCASE" in
VFP,which takes not only equality but also other boolean expressions at
every case.If the expression is true, the coomands just after this case
excutes,ignoring other case,no matter they are true or not.I think it
much more convenient.
For example,to classify people by age,you code like this:
DO CASE
CASE age<3
kind=baby
CASE age<14
kind=child
CASE age<18
kind=adolescent
OTHERWISE
kind=adult
As to Java,the best way to achieve it is to use "if-else",only if we
divide people by 5,10,15,20, the "switch" is useful.