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
| import UIKit | |
| protocol Tapper: class { | |
| func install() | |
| func foo() | |
| } | |
| extension Tapper where Self: UIViewController { | |
| func install() { | |
| view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "foo")) |
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
| // | |
| // main.swift | |
| // findsize | |
| // | |
| // Created by Ray Fix on 2/6/16. | |
| // Copyright © 2016 Neko Labs. All rights reserved. | |
| // | |
| import Foundation |
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
| //: Second Type Erasure | |
| import Foundation | |
| protocol Pokemon { | |
| typealias Power | |
| func attack(power: Power) | |
| } | |
| private class _AnyPokemonBoxBase<Power>: Pokemon { |
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
| protocol Actionable { | |
| func action() | |
| } | |
| enum Planets: Actionable { | |
| case Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune | |
| } | |
| protocol PlanetsKind {} |
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
| import UIKit | |
| import XCPlayground | |
| var str = "Hello, playground" | |
| XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
| let config = NSURLSessionConfiguration.defaultSessionConfiguration() | |
| config.HTTPAdditionalHeaders = ["foo": "bar"] |
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
| struct PokeCorrall { | |
| let rows: Int, columns: Int | |
| var grid: [Double] | |
| init(rows: Int, columns: Int) { | |
| self.rows = rows | |
| self.columns = columns | |
| grid = Array(count: rows * columns, repeatedValue: 0.0) | |
| } | |
| func indexIsValidForRow(row: Int, column: Int) -> Bool { |
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| extension String { | |
| var isBlank: Bool { | |
| return trimmingCharacters(in: CharacterSet.whitespaces).isEmpty | |
| } | |
| } |
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
| //: Cards | |
| import Foundation | |
| enum CardColor { | |
| case red, black | |
| } | |
| enum CardSuit: CustomStringConvertible { | |
| case heart, diamond, club, spade |
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
| /** | |
| * Copyright (c) 2016 Razeware LLC | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| * of this software and associated documentation files (the "Software"), to deal | |
| * in the Software without restriction, including without limitation the rights | |
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| * copies of the Software, and to permit persons to whom the Software is | |
| * furnished to do so, subject to the following conditions: | |
| * |
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
| import Foundation | |
| private enum RandomSource { | |
| static private let file = fopen("/dev/urandom","r")! | |
| static private let queue = DispatchQueue(label: "random") | |
| static func get(count: Int) -> [Int8] { | |
| let capacity = count + 1 // fgets adds null termination | |
| var data = UnsafeMutablePointer<Int8>.allocate(capacity: capacity) | |
| defer { | |
| data.deallocate(capacity: capacity) |