Last active
January 30, 2022 13:40
-
-
Save philipheinser/deb95ca4e046c294ad33 to your computer and use it in GitHub Desktop.
Better Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BetterSwift.swift | |
// Quatierbuch Lappen | |
// | |
// Created by Philip Heinser on 04.05.15. | |
// Copyright (c) 2015 Philip Heinser. All rights reserved. | |
// | |
import Foundation | |
// Javascript like null check | |
infix operator ||| { associativity left precedence 160 } | |
func |||<T> (left: T?, right: T) -> T { | |
if let l = left { return l } | |
return right | |
} | |
// execute on main thread | |
prefix operator %% {} | |
prefix func %% (right: ()->Void) { | |
dispatch_async(dispatch_get_main_queue(),{ | |
right() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment