- Short way to unwrap optional value for Swift.
- Use
BlueIntentExtension
proxy as customization point for constrained protocol extensions.
To run the example project, clone the repo, and run pod install
from the Example directory first.
BlueIntentCore is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'BlueIntentCore'
import BlueIntentBase
unwrap optional value
let string: String? = "test"
// unwrap
string.let { it in
// it is wrapped value
}
// unwrap, with default value
string = string.let {
return "test"
} let: { it in
// it is wrapped value
}
Use BlueIntentExtension
proxy as customization point for constrained protocol extensions
extension String: BlueIntentCompatible { }
extension BlueIntentExtension where Base == String {
public var length: Int {
return base.count
}
}
let string = "test"
string.bi.length
BlueIntentExtension & Unwrap
let string: String? = "test"
// unwrap
string?.bi.let { it in
// it is wrapped value
XCTAssert(it == "test")
}
make
qiuzhifei, qiuzhifei521@gmail.com
- https://kotlinlang.org/docs/scope-functions.html#return-value
- https://developer.apple.com/documentation/swift/optional
- https://github.com/ReactiveX/RxSwift/blob/main/RxSwift/Reactive.swift
BlueIntentCore is available under the MIT license. See the LICENSE file for more info.