Skip to content

Commit

Permalink
AnyObject -> Any
Browse files Browse the repository at this point in the history
  • Loading branch information
BasThomas committed Nov 10, 2016
1 parent b28c455 commit d888ea4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -16,7 +16,7 @@ Using this µframework instead of rolling your own `Result` type allows you to e
Use `Result` whenever an operation has the possibility of failure. Consider the following example of a function that tries to extract a `String` for a given key from a JSON `Dictionary`.

```swift
typealias JSONObject = [String: AnyObject]
typealias JSONObject = [String: Any]

enum JSONError: Error {
case noSuchKey(String)
Expand All @@ -37,7 +37,7 @@ func stringForKey(json: JSONObject, key: String) -> Result<String, JSONError> {
}
```

This function provides a more robust wrapper around the default subscripting provided by `Dictionary`. Rather than return `AnyObject?`, it returns a `Result` that either contains the `String` value for the given key, or an `ErrorType` detailing what went wrong.
This function provides a more robust wrapper around the default subscripting provided by `Dictionary`. Rather than return `Any?`, it returns a `Result` that either contains the `String` value for the given key, or an `ErrorType` detailing what went wrong.

One simple way to handle a `Result` is to deconstruct it using a `switch` statement.

Expand Down

0 comments on commit d888ea4

Please sign in to comment.