Skip to content

Instantly share code, notes, and snippets.

@aryaxt
aryaxt / Swift Ordered Dictionary
Created August 15, 2014 16:20
Swift Ordered Dictionary
public class OrderedDictionary <K: Hashable, V> {
typealias Key = K
typealias Value = V
private final var dictionary = [K: V]()
private final var orderedKeys = [K]()
init() {
}
@aryaxt
aryaxt / Swift debug log operator
Created August 7, 2014 01:12
An operator to log an object description only in debug mode
operator postfix ^ {}
@postfix func ^ <T> (object: T?) -> T? {
#if DEBUG
println(object)
#endif
return object
}
@aryaxt
aryaxt / Swift DefaultIfNil operator
Last active August 29, 2015 14:04
Swift default if nil operator
infix operator ||= {}
func ||= <T> (first: T?, second: T) -> T {
if let l = first {
return l
}
return second
}