I hereby claim:
- I am werediver on github.
- I am werediver (https://keybase.io/werediver) on keybase.
- I have a public key ASDVl2sxFUxEvo7PVGoMPO5s152IjIIoS-f3PkJ284jUJAo
To claim this, I am signing this object:
/// Cast the argument to the infered function return type. | |
func autocast<T>(some: Any) -> T? { | |
return some as? T | |
} | |
protocol Foo { | |
static func foo() -> Self | |
} | |
class Vehicle: Foo { |
protocol ServiceLocator { | |
func getService<T>() -> T? | |
} | |
final class BasicServiceLocator: ServiceLocator { | |
// Service registry | |
private lazy var reg: Dictionary<String, Any> = [:] | |
private func typeName(some: Any) -> String { |
import Foundation | |
protocol ServiceLocator { | |
func getService<T>(type: T.Type) -> T? | |
func getService<T>() -> T? | |
} | |
extension ServiceLocator { |
enum AntGrammar: Grammar { | |
enum Failure: Error { | |
case invalidCodon | |
} | |
static func generate(_ rule: GenotypeIterating) throws -> String { | |
return try prog(rule) | |
} |
import Foundation | |
func dispatch_async_batch(tasks: [() -> ()], limit: Int, completion: (() -> ())?) { | |
if tasks.count > 0 || completion != nil { | |
let q = dispatch_queue_create("dispatch_async_batch", DISPATCH_QUEUE_CONCURRENT); | |
let sema = dispatch_semaphore_create(limit); | |
dispatch_async(q, { | |
for task in tasks { | |
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER) |
import Foundation | |
func fatalError<T>(@autoclosure message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> T { | |
fatalError(message(), file: file, line: line) | |
} | |
// Demo | |
protocol ResultType { |
I hereby claim:
To claim this, I am signing this object:
// CurryLight.swift | |
func curry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, U>(f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25) -> U) -> (T1) -> (T2) -> (T3) -> (T4) -> (T5) -> (T6) -> (T7) -> (T8) -> (T9) -> (T10) -> (T11) -> (T12) -> (T13) -> (T14) -> (T15) -> (T16) -> (T17) -> (T18) -> (T19) -> (T20) -> (T21) -> (T22) -> (T23) -> (T24) -> (T25) -> U { | |
return { (x1: T1) -> (T2) -> (T3) -> (T4) -> (T5) -> (T6) -> (T7) -> (T8) -> (T9) -> (T10) -> (T11) -> (T12) -> (T13) -> (T14) -> (T15) -> (T16) -> (T17) -> (T18) -> (T19) -> (T20) -> (T21) -> (T22) -> (T23) -> (T24) -> (T25) -> U in { (x2: T2) -> (T3) -> (T4) -> (T5) -> (T6) -> (T7) -> (T8) -> (T9) -> (T10) -> (T11) -> (T12) -> (T13) -> (T14) -> (T15) -> (T16) -> (T17) -> (T18) -> (T19) -> (T20) -> (T21) -> (T22) -> (T23) -> (T24) -> (T25) -> U in { (x3: T3) -> (T4) -> (T5) -> (T6) -> (T7) -> (T8) -> (T9) -> (T10) |
// Swift 2.2 | |
enum AccessLevel { | |
case Default | |
case Private | |
case Internal | |
case Public | |
var asPrefix: String { | |
switch self { |
//: Playground - noun: a place where people can play | |
import UIKit | |
// MARK: - Skeleton | |
protocol StyleProtocol { | |
func apply(to some: Any) | |
} |