@@ -17,8 +17,8 @@ public extension Dictionary where Key == String, Value == Any {
17
17
subscript< T> ( key: Key , as type: T . Type ) -> T ? {
18
18
let any = self [ key]
19
19
return if let value = any as? T { value }
20
- else if let value = any as? NSNumber { value. as ( type) }
21
- else if let value = any as? NSString { value. as ( type) }
20
+ else if let value = any as? NSNumber { value. castTo ( type) }
21
+ else if let value = any as? NSString { value. castTo ( type) }
22
22
else { nil }
23
23
}
24
24
}
@@ -27,14 +27,14 @@ public extension Array where Element == Any {
27
27
subscript< T> ( index: Index , as type: T . Type ) -> T ? {
28
28
let any = self [ try: index]
29
29
return if let value = any as? T { value }
30
- else if let value = any as? NSNumber { value. as ( type) }
31
- else if let value = any as? NSString { value. as ( type) }
30
+ else if let value = any as? NSNumber { value. castTo ( type) }
31
+ else if let value = any as? NSString { value. castTo ( type) }
32
32
else { nil }
33
33
}
34
34
}
35
35
36
- public extension NSNumber {
37
- func `as` < T> ( _ type: T . Type ) -> T ? {
36
+ fileprivate extension NSNumber {
37
+ func castTo < T> ( _ type: T . Type ) -> T ? {
38
38
if let value = self as? T {
39
39
return value
40
40
}
@@ -61,7 +61,7 @@ public extension NSNumber {
61
61
}
62
62
}
63
63
public extension NSString {
64
- func `as` < T> ( _ type: T . Type ) -> T ? {
64
+ func castTo < T> ( _ type: T . Type ) -> T ? {
65
65
if let value = self as? T {
66
66
return value
67
67
}
0 commit comments