0

There is my code:

func singleInterpolation(value1: T, value2: T) -> T {
    return value1 + (value2 - value1) / 2
}

I've got the error: Binary operator "-" cannot be applied to two T operands

Which protocol I need to use for fix that?

  • 2
    http://stackoverflow.com/questions/34125637/binary-operator-cannot-be-applied-to-two-t-operands – Lukesivi Jan 28 '16 at 08:02
  • Sorry, but it's not good example. It shouldn't be custom protocol – Ilya Kharabet Jan 28 '16 at 08:06
  • You're receiving a similar error. Search on SO for the error you're receiving there are dozens of similar questions. The question I posted has a good answer to reference. – Lukesivi Jan 28 '16 at 08:21
  • @IlyaKharabet you have exactly the same problem as in the referenced question, and the solution and the comments over there should answer your question. – Cristik Jan 28 '16 at 08:26
  • 1
    What is `T` and where is it defined? What result do you expect if `T` is – for example – `String`? – Martin R Jan 28 '16 at 08:29

0 Answers0