Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- infix operator ??? : TernaryPrecedence
- infix operator ||| : AdditionPrecedence
- func ???(input: String?, valuesBlock: ((String?) -> String)) -> String {
- return valuesBlock(input)
- }
- func |||(ifNotNil: String, ifNil: String) -> ((String?) -> String) {
- return { (input: String?) -> String in
- if let _ = input {
- return ifNotNil
- } else {
- return ifNil
- }
- }
- }
- var anotherOptionalValue: String? = nil
- let notNil = anotherOptionalValue ??? valueIfNotNil ||| valueIfNil
- print("notNil: \(notNil)")
- anotherOptionalValue = "string"
- let yeahItsNil = anotherOptionalValue ??? valueIfNotNil ||| valueIfNil
- print("yeahItsNil: \(yeahItsNil)")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement