Inscrutable Swift compiler error when comparing two object arrays -
i'm trying compare 2 object arrays this:
if oneobjectarray != anotherobjectarray { // ... stuff }
however following less helpful compiler error:
binary operator '!=' cannot applied operands of type '[mymodelobject]' , '[(mymodelobject)]'`
the compiler error points first operand in equality check.
i think problem have not made myobectmodel
equatable.
in order check equality of 2 arrays of myobjectmodel
need able check equality of 2 myobjectmodel
objects.
to need following...
extension myobjectmodel: equatable {} // top level function func ==(lhs: myobjectmodel, rhs: myobjectmodel) -> bool { // check if objects equal here... return lhs.name == rhs.name }
Comments
Post a Comment