From bash manual
Shell variables are allowed as operands; parameter expansion is performed before the expression is evaluated. Within an expression, shell variables may also be referenced by name without using the parameter expansion syntax. A shell variable that is null or unset evaluates to 0 when referenced by name without using the parameter expansion syntax. The value of a variable is evaluated as an arithmetic expression when it is referenced, or when a variable which has been given the integer attribute using ‘declare -i’ is assigned a value. A null value evaluates to 0. A shell variable need not have its integer attribute turned on to be used in an expression.
What does "The value of a variable is evaluated as an arithmetic expression when it is referenced, or when a variable which has been given the integer attribute using ‘declare -i’ is assigned a value" mean?
Is the variable assumed to be used as an operand in an arithmetic expression? var=3+4
alone will not be evaluated as an arithmetic expression.
Can you give an example for the case "when it is referenced", and an example for the case "when a variable which has been given the integer attribute using ‘declare -i’ is assigned a value"?
Thanks.