Swiftpack.co - dankinsoid/UnwrapOperator as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by dankinsoid.
dankinsoid/UnwrapOperator 0.1.0
Convenient operator for optional values
⭐️ 0
🕓 4 years ago
.package(url: "https://github.com/dankinsoid/UnwrapOperator.git", from: "0.1.0")

UnwrapOperator

CI Status Version License

Description

Convenient operator for optional values

Usage

var optionalValue: Int?
...
let value: Int = try optionalValue~!
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<Wrapped> in some interesting ways:

extension Array where Element: OptionalProtocol {...}

Installation

  1. CocoaPods Add the following line to your Podfile:

    pod 'UnwrapOperator'
    

    and run pod update from the podfile directory first.

  2. Swift Package Manager Create a Package.swift file.

    // 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"])
      ]
    )
    
    $ swift build
    

Author

Voidilov, [email protected]

License

UnwrapOperator is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 0
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics