Are inout variables of protocol type prohibited?
问题 The following code: protocol SomeProtocol {} class SomeClass: SomeProtocol {} private func doSomethingWith(inout someVar: SomeProtocol) {} private var someGlobalVar = SomeClass() // inferring SomeClass's type doSomethingWith(&someGlobalVar) produces the following error: Cannot invoke 'doSomethingWith' with an argument list of type '(inout SomeClass)' Changing the penultimate line to private var someGlobalVar: SomeProtocol = SomeClass() resolves the error. Subj. 回答1: When you assign a