Binary operator '+' cannot be applied to two 'T' operands

后端 未结 3 1382
感动是毒
感动是毒 2020-12-31 04:12

I am using Generics to add different types like Int, Double, Float, etc. I used the code below but I\'m getting error \"Binary operator \'+\' cannot be applied to two \'T\'

3条回答
  •  情书的邮戳
    2020-12-31 04:24

    For those who wish to use comparison such as < , > etc, simply tell Swift that your generic type adopt to comperable protocol like so: -

    func genericComparison(left: LinkedList, right: LinkedList) -> LinkedList

提交回复
热议问题