Skip to content

Commit

Permalink
Use properties for all NSNumber transformations
Browse files Browse the repository at this point in the history
The casts with `as` have worked up until now, but really this feels like
it's more explicit, more future proof, and possibly more efficient.
  • Loading branch information
gfontenot committed Nov 2, 2016
1 parent b097b1f commit b29a86b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Argo/Types/StandardTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension Int: Decodable {
*/
public static func decode(_ json: JSON) -> Decoded<Int> {
switch json {
case let .number(n): return pure(n as Int)
case let .number(n): return pure(n.intValue)
default: return .typeMismatch(expected: "Int", actual: json)
}
}
Expand Down Expand Up @@ -116,7 +116,7 @@ extension Double: Decodable {
*/
public static func decode(_ json: JSON) -> Decoded<Double> {
switch json {
case let .number(n): return pure(n as Double)
case let .number(n): return pure(n.doubleValue)
default: return .typeMismatch(expected: "Double", actual: json)
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ extension Bool: Decodable {
public static func decode(_ json: JSON) -> Decoded<Bool> {
switch json {
case let .bool(n): return pure(n)
case let .number(n): return pure(n as Bool)
case let .number(n): return pure(n.boolValue)
default: return .typeMismatch(expected: "Bool", actual: json)
}
}
Expand Down

0 comments on commit b29a86b

Please sign in to comment.