Expression

An expression is a piece of source code that produces a value at runtime.

Related concepts:  EvaluationValue

Closest Wikipedia entry:  Expression (computer science) — In computer science, an expression is a syntactic entity in a programming language that may be evaluated to determine its value. It is a combination of one or more constants, variables, functions, and operators that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce ("to return", in a stateful environment) another value. This process, for mathematical expressions, is called evaluation.

Misconceptions about Expression
51 documented Misconceptions

Check Yourself
Misconception
ArithmeticPlusPrecedesJava
Addition has higher precedence than string concatenation
Misconception
ArrowFunctionNoImpliedReturnJavaScript
Even when an arrow function consists just of an expression, the return keyword must be explicitly written
Misconception
ArrowFunctionRequiresFunctionKeywordJavaScript
Arrow functions also require the keyword 'function'
Misconception
AssignComparesJava
= compares two values
Misconception
AssignComparesPython
= compares two values
Misconception
AssignmentNotExpressionJava
An assignment a=b is not an expression
Misconception
CannotChainAttributeToObjectInstantiationPython
Method calls, and attribute accesses in general, cannot be chained to a constructor invocation.
Misconception
CannotChainMemberAccessesJava
Member accesses cannot be chained together
Misconception
CannotChainMemberToConstructorJava
Method calls or field accesses cannot be chained to a constructor invocation
Misconception
ChainedMethodsNotCalledFromOutsideJava
Chained methods are all called on the object at the beginning of the chain
Misconception
CompareBooleanToConstantScratch
To test whether an expression evaluates to true or false, one must compare it to a constant
Misconception
ComparisonWithBoolLiteralPython
To test whether an expression is True or False, one must compare it to True or to False
Misconception
ComparisonWithBooleanLiteralJava
To test whether an expression is true or false, one must compare it to true or to false
Misconception
CompositeExpressionsUntypedJava
Expressions that consist of multiple parts have no type
Misconception
ConditionalOperatorNotExpressionJavaScript
The conditional operator is not an expression
Misconception
EqualityOperatorComparesListIdentitiesScratch
(list a) = (list b) compares the identities of list a and list b
Misconception
EqualityOperatorComparesObjectsValuesJava
o==p compares the objects referred to by variables o and p
Misconception
EqualsComparesReferencesJava
o.equals(p) compares the references stored in the variables o and p
Misconception
ExpressionAssignsJava
An expression that reads a variable also updates its value after the evaluation
Misconception
ExpressionAssignsScratch
An expression that reads a variable also updates its value after the evaluation
Misconception
ExpressionsDynamicallyTypedJava
One has to evaluate an expression to determine its type
Misconception
IdentifierAsStringInBracketNotationJavaScript
An identifier used to access a property with the bracket notation is treated as a string
Misconception
InlineCallInExpressionTreeJava
The expression tree of an expression involving a call inlines the call's computation of the returned value
Misconception
InlineVariableInExpressionTreeJava
The expression tree of an expression involving a variable inlines the variable's definition
Misconception
LargeIntegerLongJava
Large integer numbers have type long
Misconception
LiteralNoExpressionJava
A literal is not an expression
Misconception
MandatoryAssignmentJavaScript
An expression must be assigned to have a valid statement
Misconception
MapToBooleanWithConditionalOperatorJava
To map a boolean expression to a boolean, a conditional operator is necessary
Misconception
MapToBooleanWithTernaryOperatorPython
To map a boolean expression to a bool, a ternary conditional operator is necessary
Misconception
NoAtomicExpressionJava
Expressions must consist of more than one piece
Misconception
NoAtomicExpressionJavaScript
Expressions must consist of more than one piece
Misconception
NoAtomicExpressionPython
Expressions must consist of more than one piece
Misconception
NoFunctionCallsChainingJavaScript
It is not allowed to chain function calls
Misconception
NoShortCircuitJava
&& and || always evaluate both operands
Misconception
NoShortCircuitPython
and/or always evaluate both operands
Misconception
ObjectsMustBeNamedJava
A variable is needed to instantiate an object
Misconception
ObjectsMustBeNamedPython
A variable is needed to instantiate an object
Misconception
OutsideInFunctionNestingPython
Nested function calls are invoked outside in
Misconception
OutsideInMethodNestingJava
Nested method calls are invoked outside in
Misconception
ParenthesesOnlyIfArgumentJava
() are optional for method calls without arguments
Misconception
ParenthesesOnlyIfArgumentPython
() are optional for function calls without arguments
Misconception
PlusConcatenatesNumbersPython
The plus operator can concatenate strings and numbers
Misconception
RightToLeftChainingJava
Chained accesses are invoked from right to left
Misconception
RightToLeftChainingPython
Chained accesses are invoked from right to left
Misconception
SelfNoExpressionPython
The name self is not an expression
Misconception
StringPlusStringifiesExpressionJava
String concatenation stringifies non-String operand expressions
Misconception
TargetTypingJava
The type of a numerical expression depends on the type expected by the surrounding context
Misconception
ThisChildInCallExpressionJava
Instance method or constructor call nodes in expression trees have a child labeled "this"
Misconception
ThisNoExpressionJava
The name this is not an expression
Misconception
VariablesHoldExpressionsJava
= stores an expression in a variable
Misconception
VariablesHoldExpressionsPython
= stores an expression: it stores a reference to the expression in a variable

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.