Use switch syntax in resolve functions
This commit is contained in:
@@ -87,19 +87,16 @@ public func ==(lhs: Variable, rhs: Variable) -> Bool {
|
|||||||
|
|
||||||
|
|
||||||
func resolveDictionary(current: Any?) -> [String: Any]? {
|
func resolveDictionary(current: Any?) -> [String: Any]? {
|
||||||
if let dictionary = current as? [String: Any] {
|
switch current {
|
||||||
|
case let dictionary as [String: Any]:
|
||||||
return dictionary
|
return dictionary
|
||||||
}
|
case let dictionary as [String: AnyObject]:
|
||||||
|
|
||||||
if let dictionary = current as? [String: AnyObject] {
|
|
||||||
var result: [String: Any] = [:]
|
var result: [String: Any] = [:]
|
||||||
for (k, v) in dictionary {
|
for (k, v) in dictionary {
|
||||||
result[k] = v as Any
|
result[k] = v as Any
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
case let dictionary as NSDictionary:
|
||||||
|
|
||||||
if let dictionary = current as? NSDictionary {
|
|
||||||
var result: [String: Any] = [:]
|
var result: [String: Any] = [:]
|
||||||
for (k, v) in dictionary {
|
for (k, v) in dictionary {
|
||||||
if let k = k as? String {
|
if let k = k as? String {
|
||||||
@@ -107,26 +104,23 @@ func resolveDictionary(current: Any?) -> [String: Any]? {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
default:
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func resolveArray(current: Any?) -> [Any]? {
|
func resolveArray(current: Any?) -> [Any]? {
|
||||||
if let current = current as? [Any] {
|
switch current {
|
||||||
return current
|
case let array as [Any]:
|
||||||
}
|
return array
|
||||||
|
case let array as [AnyObject]:
|
||||||
if let current = current as? [AnyObject] {
|
return array.map { $0 as Any }
|
||||||
return current.map { $0 as Any }
|
case let array as NSArray:
|
||||||
}
|
return array.map { $0 as Any }
|
||||||
|
default:
|
||||||
if let current = current as? NSArray {
|
|
||||||
return current.map { $0 as Any }
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func normalize(current: Any?) -> Any? {
|
func normalize(current: Any?) -> Any? {
|
||||||
if let array = resolveArray(current) {
|
if let array = resolveArray(current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user