Since different languages have different definitions for an expression and a statement, what is the difference between them in Dart?
I'm still new to Dart but with previous knowledge (and reading dart language tour):
condition ? expr1 : expr2
has a value of expr1
or expr2
.A statement
contains expressions
, but an expression
can’t contain a statement
.
Above is my explanation of bullet point I tried to simplify for you, found when reading language tour on category important concepts that goes like this:
Dart has both expressions (which have runtime values) and statements (which don’t). For example, the conditional expression
condition ? expr1 : expr2
has a value ofexpr1
orexpr2
. Compare that to an if-else statement, which has no value. A statement often contains one or more expressions, but an expression can’t directly contain a statement.