I'm trying to define the +
operator for a V type I defined for this test. Here is what I'm entering in the REPL, on my MacBook Pro:
1> struct V {
2. var x: Int, y: Int
3. }
4.
4> extension V {
5. static func + (left: V, right: V) -> V {
6. return V(x: left.x + right.x, y: left.y + right.y)
7. }
8. }
9> let a = V(x: 1, y: 2)
a: V = {
x = 1
y = 2
}
10> let b = V(x: 3, y: 4)
b: V = {
x = 3
y = 4
}
11> let c = a + b
error: repl.swift:11:11: error: binary operator '+' cannot be applied to two 'V' operands
let c = a + b
~ ^ ~
repl.swift:11:11: note: overloads for '+' exist with these partially matching parameter lists:
(Float, Float), (Double, Double), (Float80, Float80), (UInt8, UInt8), (Int8, Int8),
(UInt16, UInt16), (Int16, Int16), (UInt32, UInt32), (Int32, Int32), (UInt64, UInt64),
(Int64, Int64), (UInt, UInt), (Int, Int), (String, String), (C, S), (S, C), (RRC1, RRC2),
(Self, Self.Stride), (Self.Stride, Self), (UnsafeMutablePointer<Pointee>, Int),
(Int, UnsafeMutablePointer<Pointee>), (UnsafePointer<Pointee>, Int),
(Int,UnsafePointer<Pointee>)
let c = a + b
^
Did I write anything wrong? Is this a limitation with the REPL?
Thank you in advance for the help.