Addition (+)
Last updated
Was this helpful?
Last updated
Was this helpful?
Airkit supports the standard addition operator +
. It is used to add and values as well as combine values into a single string and types into a single List.
The following example shows how the addition operator is used to combine the Numbers 2 and 3 together. Note that it returns a another Number: 5, the sum 2 and 3:
The addition operator can be used to add Currencies provided the Currency values being added have the same currency code. For instance, say you have two Currency values, currency_1
and currency_2
, defined as follows:
currency_1
and currency_2
both represent money in US dollars, so they can be combined using the addition operator:
Currency values cannot be added if they do not have matching currency codes. For example, say there is a third Currency value, currency_3
, in Euros rather than dollars, defined as follows:
Attempting to use the addition operator to add currency_3
to currency_2
will result in an error, because the addition operator cannot add euros and US dollars:
The following example shows how the addition operator is used to combine the strings "abc" and "def". Note that it returns another string: "abc" and "def" concatenated together:
The following example shows how the addition operator is used to combine the Lists [1, 2, 3] and [a, b, c]. Note that it returns another List:
When adding strings together, the addition operator behaves analogously to the function.