Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/obbut/almostforceunwrap
Throwing force unwrap operator for Swift
https://github.com/obbut/almostforceunwrap
Last synced: 27 days ago
JSON representation
Throwing force unwrap operator for Swift
- Host: GitHub
- URL: https://github.com/obbut/almostforceunwrap
- Owner: Obbut
- Created: 2016-12-14T10:21:32.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-14T14:12:51.000Z (about 6 years ago)
- Last Synced: 2024-09-16T16:46:40.257Z (about 2 months ago)
- Language: Swift
- Size: 1.95 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AlmostForceUnwrap
Throwing force unwrap operator for SwiftThis library defines a new postfix operator, `⁉`, for Swift. It behaves like the the normal force unwrap operator(`!`) but instead of crashing your application, it throws an error.
```swift
let optionalString: String? = "Cheese"
let nonOptionalString: String = try optionalString⁉
```## Usage
Use the Swift Package Manager:
```swift
import PackageDescriptionlet package = Package(
name: "MyApp",
dependencies: [
.Package(url: "https://github.com/Obbut/AlmostForceUnwrap.git", majorVersion: 0, minor: 1)
]
)
```Import it:
```swift
import AlmostForceUnwrap
```Now you can use the operator yourself.