【发布时间】:2015-07-15 17:43:13
【问题描述】:
没有正确表达式中的类型的 typealias 有什么作用?
在示例中,如果在 BooleanLiteralConvertible 之外已经存在另一个类型别名,那么在 BooleanLiteralType 中创建它的目的是什么?它们有关系吗?
/// Conforming types can be initialized with the Boolean literals
/// `true` and `false`.
protocol BooleanLiteralConvertible {
typealias BooleanLiteralType
/// Create an instance initialized to `value`.
init(booleanLiteral value: Self.BooleanLiteralType)
}
/// The default type for an otherwise-unconstrained Boolean literal.
typealias BooleanLiteralType = Bool
【问题讨论】:
标签: swift type-alias