- 个人理解是什么?
类似java的反射 字符串到类的映射,如给一个字符串能直接初始化一个类 - 太抽象?不好懂?见效果
-
如何实现
自带许多的
typealias ALC = ExpressibleByArrayLiteral
typealias BLC = ExpressibleByBooleanLiteral
typealias DLC = ExpressibleByDictionaryLiteral
typealias FLC = ExpressibleByFloatLiteral
typealias NLC = ExpressibleByNilLiteral
typealias ILC = ExpressibleByIntegerLiteral
typealias SLC = ExpressibleByStringLiteral
class Person: ExpressibleByStringLiteral {
let name: String
init(name value: String) {
self.name = value
}required convenience init(stringLiteral value: String) { self.init(name: value) } required convenience init(extendedGraphemeClusterLiteral value: String) { self.init(name: value) } required convenience init(unicodeScalarLiteral value: String) { self.init(name: value) } }