Reputation: 34503
The print
function in a class is mysteriously generating the following error: Argument passed to call that takes no arguments
.
However, the error goes away if we use Swift.print
instead of just print
to invoke the function.
We are using Swift 2 and Xcode 7.
Why does this happen?
Test function below where the error gets generated:
func test() {
print("why does this fail")
}
Upvotes: 2
Views: 3353
Reputation: 539705
However, the error goes away if we use
Swift.print
instead of just
That means that there is a print()
method defined in your class
or in one of its superclasses, so that print()
is resolved as
the method call self.print()
.
By prefixing the module name "Swift" you refer to the global print()
function instead.
Upvotes: 10