https://github.com/muukii/unwrap
let _self = try self.unwrapped()
https://github.com/muukii/unwrap
Last synced: about 1 month ago
JSON representation
let _self = try self.unwrapped()
- Host: GitHub
- URL: https://github.com/muukii/unwrap
- Owner: muukii
- License: mit
- Created: 2016-04-27T07:33:47.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-01T16:22:49.000Z (over 8 years ago)
- Last Synced: 2025-03-12T02:37:25.951Z (2 months ago)
- Language: Swift
- Homepage:
- Size: 23.4 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unwrap
[](https://travis-ci.org/muukii/Unwrap)
[](http://cocoapods.org/pods/Unwrap)
[](http://cocoapods.org/pods/Unwrap)
[](http://cocoapods.org/pods/Unwrap)
[](https://github.com/Carthage/Carthage)Syntax sugar for unwrapping while throwing error for nil
With this syntax sugar you can unwrap variables while throwing error for nil.
It's useful in closures/functions with throw.```swift
func unwrapped(error: Error = UnwrapError.FailedToUnwrap) throws -> Optional.Wrapped {
```## Usage
```swift
let bar: Int? = 3
``````swift
let v: Int = try bar.unwrapped()
```### Advanced
```swift
{ [weak self] in
let _self = try self.unwrapped()
}
```- RxSwift
```swift
operation
.doOnNext { [weak self] i
let _self = try self.unwrapped()
_self.value = "abc"
}
```## Requirements
## Installation
Unwrap is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "Unwrap"
```## Author
muukii, [email protected]
## License
Unwrap is available under the MIT license. See the LICENSE file for more info.