We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
结构只能从协议继承(如果正确的话)。 不能从基本结构继承,所以您不能做
struct Resolution { var width = 0 var height = 0 } struct MyStruct: Resolution { ... } // ERROR!
因此,有两个选择。 第一种是改用类。 第二个是重构代码以使用协议。
因此,有一些常用方法,则可以执行以下操作:
protocol PixelContainer { var width: Int { get } var height: Int { get } } extension PixelContainer { var count: Int { return width * height } } struct Resolution: PixelContainer { var width = 10 var height = 20 } let numPixels = Resolution().count // Legal
The text was updated successfully, but these errors were encountered:
No branches or pull requests
结构只能从协议继承(如果正确的话)。 不能从基本结构继承,所以您不能做
因此,有两个选择。 第一种是改用类。 第二个是重构代码以使用协议。
因此,有一些常用方法,则可以执行以下操作:
The text was updated successfully, but these errors were encountered: