swift - Overriding a function outside its class -
i came across strange behaviour. following code produces compile error call bar() message: "missing argument parameter #1 call" func bar() { println("bar no argument") } class classa { func bar(varofanytype: string) { println("bar argument") } func foo() { bar() } } if change bar() function's name no errors: func barnamechanged() { println("bar no argument") } class classa { func bar(varofanytype: string) { println("bar argument") } func foo() { barnamechanged() } } what's reason compiler not allowing override function outside class? cheers, daniel at moment, swift compiler cannot distinguish between method , global function same name, regardless of overloading. the solution prefix global function module name, e.g., func bar() { } class classa { func bar(anything: string) {} func foo() { module.bar() } }