Skip to content

Multiply Operator

IsaacShelton edited this page Mar 21, 2022 · 1 revision

* Operator (Multiplication)

The * operator is used for multiplying two numeric types.

1 * 2

Override

The * operator can be defined for non-numeric types or type combinations with the following:

func __multiply__(a $A, b $B) $C 

where $A, $B and $C are any valid types

See __multiply__ for more information.

Other Uses

A common usage of the * operator (for non-numeric types) is repeating a String value:

"\n" * 10

Allowed by the following definition:

func __multiply__(lhs String, times int) String
Clone this wiki locally