Skip to content

Instantly share code, notes, and snippets.


Becca Royal-Gordon beccadax

View GitHub Profile
View gist:daa9e2112f9c6aa4a5720cf5e81febb6
<?xml version="1.0"?>
\( "")
typealias ChapterTuple = (heading: String)
typealias BookTuple = (id: String, author: String, title: String, genre: String, price: String, chapters: [ChapterTuple])
View optionalequality.swift
// Evaluates the given closure when two `Optional` instances are not `nil`,
// passing the unwrapped values as parameters. (Thanks, Mike Ash, Tim Vermeulen)
// Following the example of IEEE754 with NAN, any comparison involving
// .None is false
// See also:
/// Returns nil if either parameter is nil, or a tuple of the parameters
/// otherwise.
func all<T, U>(_ first: T?, _ second: U?) -> (T, U)? {

Tuple-Based Compound Optional Binding


This proposal enhances optional binding with a new, tuple-based syntax for


Introducing with to the Standard Library


This proposal introduces a with function to the standard library. This function

beccadax / Distance.swift
Last active Aug 29, 2015 — forked from fcanas/Distance.swift
Creating a Numeric Type : Distance
View Distance.swift
public struct Distance :NumericType {
public var value :Double
public init(_ value: Double) {
self.value = value
extension Distance :IntegerLiteralConvertible {
public init(integerLiteral: IntegerLiteralType) {
View Stupid overloading tricks
extension String {
func split(separator:String) -> [String] {
return self.componentsSeparatedByString(separator)
extension Array {
func unpack() -> (T)? {
return count == 1 ? (self[0]) : nil