Here's a contrived example:
class AwesomeClass {
var answerToEverything: NSInteger = 42
class func answerToEverything() -> NSInteger {
return 42
}
}
Per my Swift understanding, there should be no issue here: var answerToEverything and class func answerToEverything have different signatures: var answerToEverything applies to the instance and class func answerToEverything() to the class.
However, this gives a compiler error:
Invalid redeclaration of 'answerToEverything()
Why does an instance parameter and class function with same names give this error?
In case it matters, I'm using Xcode 7.3 (7D175).
Note: it makes sense why an instance method and instance parameter can't have the same name. The compiler couldn't distinguish them. However, this question is about a class method and an instance parameter. This is different from the proposed duplicate question.
AFAIK, the compiler should be able clear distinguish them.How? Why do think so?