Addition (+)

Airkit supports the standard addition operator +. It is used to add Number and Currency values as well as combine Text values into a single string and List types into a single List.

Examples

Adding Numbers

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:

2 + 3 -> 5

Adding Currency

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 -> {
  "amount": 3000,
  "code": "USD",
  "precision": 2
}
currency_2 -> {
  "amount": 1000,
  "code": "USD",
  "precision": 2
}

currency_1 and currency_2 both represent money in US dollars, so they can be combined using the addition operator:

currency_1 + currency_2 -> {
  "amount": 4000,
  "code": "USD",
  "precision": 2
}

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:

currency_3 -> {
  "amount": 2000,
  "code": "EURO",
  "precision": 2
}

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:

currency_3 + currency_2 -> ERROR

Adding Text

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:

"abc" + "def" -> "abcdef"

When adding strings together, the addition operator behaves analogously to the CONCAT function.

Adding Lists

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:

[1, 2, 3] + ["a", "b", "c"] -> [1, 2, 3, "a", "b", "c"]