Skip to content

Commit

Permalink
Fix transform sample for Swift2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroraba authored and tristanhimmelman committed Dec 22, 2015
1 parent 0ec2d17 commit 8b81aae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ For example, if you want to transform a JSON String value to an Int you could us
```swift
let transform = TransformOf<Int, String>(fromJSON: { (value: String?) -> Int? in
// transform value from String? to Int?
return value?.toInt()
return Int(value!)
}, toJSON: { (value: Int?) -> String? in
// transform value from Int? to String?
if let value = value {
Expand All @@ -170,7 +170,7 @@ id <- (map["id"], transform)
```
Here is a more condensed version of the above:
```swift
id <- (map["id"], TransformOf<Int, String>(fromJSON: { $0?.toInt() }, toJSON: { $0.map { String($0) } }))
id <- (map["id"], TransformOf<Int, String>(fromJSON: { Int($0!) }, toJSON: { $0.map { String($0) } }))
```

# Subclasses
Expand Down

0 comments on commit 8b81aae

Please sign in to comment.