https://github.com/dankinsoid/unwrapoperator
Convenient operator for optional values
https://github.com/dankinsoid/unwrapoperator
Last synced: 10 months ago
JSON representation
Convenient operator for optional values
- Host: GitHub
- URL: https://github.com/dankinsoid/unwrapoperator
- Owner: dankinsoid
- License: other
- Created: 2019-08-08T13:46:22.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-16T13:32:17.000Z (almost 7 years ago)
- Last Synced: 2025-08-10T19:46:03.660Z (10 months ago)
- Language: Swift
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UnwrapOperator
[](https://travis-ci.org/Voidilov/UnwrapOperator)
[](https://cocoapods.org/pods/UnwrapOperator)
[](https://cocoapods.org/pods/UnwrapOperator)
## Description
Convenient operator for optional values
## Usage
```swift
var optionalValue: Int?
...
let value: Int = try optionalValue~!
```
```swift
var optionalInt: Int?
var optionalString: String?
try? someFunc(value1: optionalInt~!, value2: optionalString~!)
//instead of
//if let int = optionalInt, let string = optionalString {
// someFunc(value1: int, value2: string)
//}
...
func someFunc(value1: Int, value2: String)
```
`OptionalProtocol` - protocol that allows you to work with `Opational` in some interesting ways:
```swift
extension Array where Element: OptionalProtocol {...}
```
## Installation
1. [CocoaPods](https://cocoapods.org)
Add the following line to your Podfile:
```ruby
pod 'UnwrapOperator'
```
and run `pod update` from the podfile directory first.
2. [Swift Package Manager](https://github.com/apple/swift-package-manager)
Create a `Package.swift` file.
```swift
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "SomeProject",
dependencies: [
.package(url: "https://github.com/dankinsoid/UnwrapOperator.git", from: "0.1.0")
],
targets: [
.target(name: "SomeProject", dependencies: ["UnwrapOperator"])
]
)
```
```ruby
$ swift build
```
## Author
Voidilov, voidilov@gmail.com
## License
UnwrapOperator is available under the MIT license. See the LICENSE file for more info.