Skip to content

Commit

Permalink
Added information about Try to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier de Silóniz Sandino committed Oct 9, 2015
1 parent 73b900e commit d9e3ffb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ matchTest.apply(1000) // "Moar!"
**Try**
`Try` is a monad that encapsulates an operation that can fail and throw an exception. As you may be aware, Swift now supports do-try-catch blocks to handle operations that can fail. `Try` can wrap throwable functions (those marked with the `throws` keyword) to handle these failures for you. The result of the wrapped operation is store in a `TryMatcher.Success(x)` if it's a valid result `x`, or `TryMatcher.Failure(ex)` if the operation has thrown an `ex` exception.
`Try` is a monad that encapsulates an operation that can fail and throw an exception. As you may be aware, Swift now supports `do-try-catch` blocks to handle operations that can fail. `Try` can wrap throwable functions (those marked with the `throws` keyword) to handle these failures for you. The result of the wrapped operation is stored in a `TryMatcher.Success(x)` if it's a valid result `x`, or `TryMatcher.Failure(ex)` if the operation has thrown an `ex` exception.
```swift
import SecondBridge
Expand Down Expand Up @@ -278,7 +278,6 @@ let flatmapCorrectResultAgainstOKFunction = tryParseCorrectString.flatMap(tryHal
flatmapCorrectResultAgainstOKFunction.isSuccess() // true
flatmapCorrectResultAgainstOKFunction.getOrElse(1) // 23
// You can also use `recover` and `recoverWith` to chain a set of
// Partial Functions that can handle failures in your `Try`s:
let recoverResult = tryParseIncorrectString.recover({
Expand Down

0 comments on commit d9e3ffb

Please sign in to comment.