Multiplication (*)

Airkit supports the standard multiplication operator *. It is used to multiply Numbers together. It can also be used to multiply a Currency value by a Number.

Example

Multiplying Numbers

The following example shows how the multiplication operator is used to multiply the Number 2 and the Number 3 together. Note that it returns a another Number: 6, the product of 1 and 3:

2 * 3 -> 6

Multiplying Currency

Say there exists a Currency value, example_currency, defined as follows:

example_currency -> {
  "amount": 3000,
  "code": "USD",
  "precision": 2
}

The multiplication operator can be used to multiply example_currency by a Number, such as in the following example, which multiplies example_currency by 2. Note that it returns a Currency:

example_currency * 2  ->  {
  "amount": 6000,
  "code": "USD",
  "precision": 2
}

It does not matter whether the Currency or the Number value is given first. The multiplication operator can be used to multiply a Number by a Currency just as well as it can be used to multiply a Currency by a Number:

2 * example_currency  ->  {
  "amount": 6000,
  "code": "USD",
  "precision": 2
}

The multiplication operator cannot be used to multiply two Currencies together.

example_currency * example_currency -> ERROR