-
-
Notifications
You must be signed in to change notification settings - Fork 9
Add Operator
IsaacShelton edited this page Mar 21, 2022
·
1 revision
The +
operator is used for adding two numeric types.
1 + 2
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.
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