can't redefine infix + operator in swift -


i wanted able add 2 (int,int) tuples. defined

func + (left:(int,int), right:(int,int))->(int,int) { return (left.0+right.0,left.1+right.1) } 

but xcode not happy, saying "consecutive declarations on line must sparated ';' ". what's wrong infix operation?

ok, leave question on since others may find useful, found answer. turns out operators can defined in global scope - @ least that's xcode told me. moved definition of + out of class in, , works. i'm still not sure if want define operator on struct, say, defined within class, hey, needed int tuples...


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -