>=(greater than or equal to),
<(less than), and
<=(less than or equal to). You can also define the operators as abbreviations:
EQ, NEQ, GT, GTE, LT, and LTE.
false, so they're used in conditional statements, for example,
trueonly when the variable is an "array". Structures have an instruction named
trueif a key is present in a structure. Strings can also be used for conditional operations by checking the
elseexpressions. Let's write an example by adding a method to our
The water is not boiling yet..
It's just barely boiling.
Hot! Hot! Hot!.
ifstatement whose instructions are executed only if the statement is true
else ifstatements whose instructions are executed only if the statement is true
elsestatement whose instructions are executed if no
else ifstatements were true
if / else if / elsestructure can have its instructions run. If the if is true, for instance, CFML will never look at the
else if. Once one block executes, that’s it.
if, else, else ifexpression statements. It is very common in other languages and can be used for a more fluent expressive conditional expression.
conditionis evaluated. If it is true, then the true statement executed; if it is false, then the false statement executes.
falseStatementinto more tenrary operations. However, don't abuse it as they will look ugly and just be very complex to debug.
IFstatements to do these kind of evaluations. They work, but not very expressive or concise.
right defaultfor a variable or an expression Or it is a short-hand way to do parameterization. It will allow us to set a value if the variable is
Nullor does not exist.
userNamedoes not exist or evaluates to
nullthen the default value of the
myNamewill be assigned the right part of the
?:elvis operator ->
key not existsexception but returning an
nullvalue. You can then combine that with the elvis operator and create nice chainable struct navigation. For example instead of doing things like:
?) along with the dot operator (
.) is known as safe navigation operator(
?.). The safe navigation operator makes sure that if the variable used before the operator is not defined or java
null, then instead of throwing an error, the operator returns
undefinedfor that particular access.
switch / case / defaultblock.
ifstatement marks the start of an
ifblock and contains one or more
else ifstatements and perhaps one (and only one)
switchstatement marks the start of a
switchblock and can contain multiple
casestatements and perhaps one (and only one)
switch / case / defaultcan only evaluate the resulting value of a single variable or expression, while the
if / else if / elseblock lets you evaluate the
true or falseresult of different variables or expressions throughout the block.
casestatements with curly braces. As best practice, do so for all
while( conditional )expression allows you to execute a code block as many times as the
conditionalexpression evaluates to true. This is a great way to work with queues, stacks or just simple evaluations.
=is an assignment. It means "take what's on the right side and stick it into whatever is on the left side" (or its telling not asking.)
==is a question. It means "is the thing on the right equal to the thing on the left" (or its asking not telling.)