Home

else

Else is primarily an adverb in English, used to refer to something other than what has already been mentioned, or to indicate an alternative or addition. Common constructions include what else, someone else, and elsewhere. In questions and negative statements, else conveys the meaning "otherwise." The term also appears in figurative phrases such as "elsewhere" or "what else can I do?"

In programming, else is a reserved keyword that introduces the alternative branch of a conditional. It is

Notes: The presence and exact semantics of else can vary by language, particularly regarding short-circuit evaluation

used
with
an
if
statement
to
specify
code
to
execute
when
the
condition
is
false.
Common
form
in
C,
Java,
JavaScript,
and
many
languages:
if
(condition)
{
/*
then
*/
}
else
{
/*
else
*/
}.
Many
languages
also
support
an
intermediate
branch,
else
if
(or
elif),
to
test
additional
conditions.
In
Python
the
syntax
is
if
condition:
...
elif
other_condition:
...
else:
...,
with
indentation
defining
blocks.
In
switch
statements,
languages
typically
use
a
default
clause
instead
of
an
else,
to
handle
all
remaining
cases.
and
side
effects.
The
else
block
is
optional;
omitting
it
results
in
no
alternate
action
when
the
if
condition
is
false.
Correct
use
of
braces
or
indentation
is
important
to
avoid
logic
errors
and
mis-scoped
blocks.