Skip to content

Add Operator

IsaacShelton edited this page Mar 21, 2022 · 1 revision

+ Operator

The + operator is used for adding two numeric types.

1 + 2

Override

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

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

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

See __add__ for more information.

Other Uses

A common usage of the + operator (for non-numeric types) is concatenating String values:

"Welcome " + "Isaac"

Allowed by these definitions:

func __add__(lhs String, rhs String) String
func __add__(lhs String, rhs ubyte) String
func __add__(lhs POD String, rhs $T~__primitive__) String
Clone this wiki locally