总得说点什么
import Foundation
struct SwiftWrapper<Base> {
var base: Base
init(_ base: Base) {
self.base = base
}
}
protocol SwiftProtocol {}
extension SwiftProtocol {
var swifter: SwiftWrapper<Self> {
return SwiftWrapper(self)
}
static var swifter: SwiftWrapper<Self>.Type {
return SwiftWrapper<Self>.self
}
}
extension String: SwiftProtocol { }
extension NSString: SwiftProtocol { }
extension SwiftWrapper where Base: ExpressibleByStringLiteral {
var numberCount: Int {
var count = 0
for c in (base as! String) where ("0"..."9").contains(c) {
count += 1
}
return count
}
static func print() {
Swift.print("static func")
}
}
let string = "243786"
print(string.swifter.numberCount)
String.swifter.print()
下面有个小姐姐
https://www.youtube.com/watch?v=DJJ_721k5-g
--EOF--
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于