swift - Can I automatically derive some instances like Equatable? -


say have struct memebers equatable.

struct s {   let : string   let b : int   let c : double } 

would know of way automatically make s equatable without manually , boringly defining ==?

no, you'll have define manually:

func == (l: s, r: s) -> bool { return l.a == r.a && l.b == r.b && l.c == r.c } 

that's short can make it. it's pretty darn short (one line!), meaning clear, , it's ready future complications may add type. happy!


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -