Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# AlmostForceUnwrap
Throwing force unwrap operator for Swift

This 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 PackageDescription

let 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.