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
Post a Comment