Swift equal function dont work -


i want check equality between objects error. error within code.

class test {     var key: string      init(nameparam: string) {         self.key = nameparam     }       func ==(other: test) -> bool {         return other.key == self.key     }  }  var t1 = test(nameparam: "test") var t2 = test(nameparam: "test1")  if(t1 == t2) { // error: 'test' not convertible 'mirrordisposition'     println("...") } 

operators must implemented in global scope, not inside class. should implement equality operator outside of class:

class test {...}  func == (lhs: test, rhs: test) -> bool {     return lhs.key == rhs.key } 

suggested reading: operator functions


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -