Given the following struct:
struct TestStruct {
func test() {
print("Something")
}
}
Referencing the test function like this works:
let testFunc = TestStruct.test // (TestStruct) -> () -> Void
In order to execute the function you would have to do the following:
testFunc(TestStruct())() // Prints "Something"
Say you make TestStruct conform to a protocol:
protocol Test {
func test()
}
extension TestStruct: Test {}
Now trying to rather reference the test function through the protocol like this does not work:
let testFunc = Test.func // Does not compile, no error message
Shouldn't the type of testFunc be (Test) -> () -> Void? And why is it now compiling?