At gwmpro at yahoo dot com
The curly brace is not required however, for readability and maintenance, many developers would consider it bad style not to include them.
else
经常需要在满足某个条件时执行一条语句,而在不满足该条件时执行其它语句,这正是
else 的功能。else 延伸了
if 语句,可以在 if
语句中的表达式的值为 FALSE 时执行语句。例如以下代码在
mitch at mitchellbeaumont dot com
24-Jul-2007 07:09
At gwmpro at yahoo dot com
robbak
21-Jun-2007 07:54
Yes, that code is clearly ambiguous. I would think that the code does the 'right thing' with it anyway. The else should bind to the nearest if.
jsimlo
15-Aug-2006 02:30
This generates a parser error:
gwmpro at yahoo dot com
04-May-2006 03:00
I am new to this language. It seems to me that only the semicolon ';' is required, the brackets '{}' are not if there is only one statement. The code segment below would be legal.
Caliban Darklock
08-Nov-2004 07:24
If you're coming from another language that does not have the "elseif" construct (e.g. C++), it's important to recognise that "else if" is a nested language construct and "elseif" is a linear language construct; they may be compared in performance to a recursive loop as opposed to an iterative loop.
cap at capsi dot com
06-Oct-2000 05:58
Often you can avoid large if/else statements in your code by using the ternary operator. For example:
| ||