Discussion 解説
Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the String(reflecting:)
initializer. This initializer works with any type, and uses the custom debug
property for types that conform to Custom
:
このプロパティを直接に呼び出すことは、推奨されません。代わりに、どんな型のインスタンスでも文字列へと、String(reflecting:)
イニシャライザを使って変換してください。このイニシャライザはどんな型とでも働きます、そしてあつらえのdebug
プロパティをCustom
に準拠する型に対して使います:
struct Point: CustomDebugStringConvertible {
let x: Int, y: Int
var debugDescription: String {
return "(\(x), \(y))"
}
}
let p = Point(x: 21, y: 30)
let s = String(reflecting: p)
print(s)
// Prints "(21, 30)"
The conversion of p
to a string in the assignment to s
uses the Point
type’s debug
property.
p
の文字列への変換はs
への代入において、Point
型のもつdebug
プロパティを使います。
Note 注意
This documentation comment was inherited from Custom
.
この文書化コメントは、Custom
から引き継がれました。