I hereby claim:
- I am burntcaramel on github.
- I am burntcaramel (https://keybase.io/burntcaramel) on keybase.
- I have a public key ASArnj22CZ7v-9tbcz-52hippT2ZfvGy4dQ3ZoSelHe3lwo
To claim this, I am signing this object:
import Foundation | |
protocol StageProtocol { | |
func perform() throws -> Self? | |
var queue: dispatch_queue_t { get } | |
func run(completion: (() throws -> Self) -> ()) | |
} |
enum Fruit { | |
case apple, pear, orange, plum | |
} | |
extension Fruit { | |
var cents: Int { | |
return switch self [ | |
.apple: 70, | |
.pear: 85, | |
.orange: 40, |
struct Person { | |
var firstName, lastName: String | |
mutating func makeScottishClan() { | |
lastName = "mc\(lastName)" | |
} | |
} | |
// Person.Mutation gets automatically created (like an enum) | |
// .firstName(String) |
//: Playground - noun: a place where people can play | |
import Foundation | |
struct ExampleStruct : Codable { | |
var title: String | |
var something: Int | |
public func encode(to encoder: Encoder) throws { |
//: Types for currency conversion | |
// https://www.natashatherobot.com/swift-money-phantom-types/ | |
import Foundation | |
struct Money { | |
enum Currency { | |
case GBP, EUR, USD | |
} |
//: Responder chain in Swift using enums | |
protocol CommandProtocol {} | |
protocol Responder: class { | |
var nextResponder: Responder? { get } | |
func performerForCommand | |
<Command : CommandProtocol> | |
(command: Command) -> (() -> ())? |
interface State { | |
counter: number | |
} | |
const counterModel = { | |
initial(): State { | |
return { | |
counter: 0 | |
}; | |
}, |
I hereby claim:
To claim this, I am signing this object:
//: Playground - noun: a place where people can play | |
import Foundation | |
protocol OptionalParasite { | |
typealias WrappedParasite | |
func toArray() -> [WrappedParasite] | |
} |
public struct Person { | |
public var firstName: String | |
public var middleName: String? | |
public var lastName: String | |
public var ageInYears: Int | |
public var fullName: String { | |
return [firstName, middleName, lastName].flatMap{ $0 }.joinWithSeparator(" ") | |
} | |
} |