Addable

public protocol Addable[Other = Self]

Raw protocol backing the + operator.

Output may differ from Self and Other — this is what allows mixed-type arithmetic (e.g. Vector + Scalar -> Vector) without losing precision. The associated zero value gives sums (and Iterator.sum) a starting point and is the additive identity by definition.

Examples

2 + 3 // 5 Int64.zero // 0

Properties

static var zero: Self { get }

The additive identity — a value z such that x + z == x for all x.

Associated Types

type Output

Methods

consuming func add(consuming Other) -> Output

Returns self + other.

Defined in lang/std/core/arithmetic.ks