9
は、インスタンスメソッド内の静的メンバの簡単使用である:静的メンバは、私のクラスのすべてのインスタンス間で共有されているので、すべてのインスタンス、なぜ「静的メンバー '...'はタイプ '...'のインスタンスで使用できません」というエラーが表示されますか?ここ
Static member
'counts'
cannot be used on instance of type'RankSet'
:
public struct RankSet {
private let rankSet : UInt8
static let counts : [UInt8] = [
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
... // More of the same
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
]
public var count : Int {
get {
// The error is on the following line
return Int(counts[Int(rankSet)])
}
}
}
スウィフトは、次のエラーが発生しcount
を含むメンバーはcounts
メンバーにアクセスする必要があります。ここで何が起こっているのですか?