Skip to content

Instantly share code, notes, and snippets.

View manuelCarlos's full-sized avatar
💭
(/¯◡ ‿ ◡)/¯ ~ ┻━┻

Manuel Carlos manuelCarlos

💭
(/¯◡ ‿ ◡)/¯ ~ ┻━┻
View GitHub Profile
@manuelCarlos
manuelCarlos / ifLetOperator.swift
Created April 4, 2017 15:47
An unwrap operator meant as a shortcut for `if let`
infix operator <-?: TernaryPrecedence
func <-? <T> ( value: inout T, ff: T?) {
if let t = ff{
value = t
}
}
func <-? <T> ( value: inout T?, ff: T?) {
@manuelCarlos
manuelCarlos / boolAssigment.swift
Last active April 4, 2017 01:29
An (unsuccessful) attempt at creating an operator that runs any closure depending on a boolean argument.
infix operator <-?
func <-? <T> (defaultValue: @autoclosure () throws -> T , condition: Bool ) rethrows -> T {
if condition{
return try defaultValue()
}
return () as! T
}