This file contains 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 | |
// ReactivePerf | |
// | |
// Created by David Hart on 09/02/16. | |
// Copyright © 2016 David Hart. All rights reserved. | |
// | |
import Foundation | |
import enum Result.NoError |
This file contains 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
let closure1: (inout Int) -> () -> Void = { a in | |
return { | |
a = 1 | |
return | |
} | |
} | |
let closure2: (UnsafeMutablePointer<Int>) -> () -> Void = { a in | |
return { | |
a.memory = 2 |
This file contains 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
class A<T> { | |
init(closure: (T -> Void) -> Void) {} | |
} | |
class B<T> : A<T> { | |
private var lastValue: T? | |
override init(closure: (T -> Void) -> Void) { | |
super.init(closure: { sink in | |
closure { value in |
This file contains 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
require 'rake' | |
task :works do | |
puts "works!" | |
end | |
class MyClass | |
include Rake::DSL | |
def self.define_task |
This file contains 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
using System.Collections.Generic; | |
interface IPublisher<T> { | |
void Subscribe(ISubscriber<T> subscriber); | |
} | |
interface ISubscriber<T> { | |
void Publish(T value); | |
} |
This file contains 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 Foundation | |
protocol ObserverType { | |
typealias Element | |
func onNext(value: Self.Element) | |
func onError() | |
func onCompleted() |
This file contains 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 ObserverType { | |
typealias Element | |
func onNext(value: Self.Element) | |
func onError() | |
func onCompleted() | |
} | |
protocol ObservableType { | |
func subscribe<T : ObserverType>(observer: T) |
This file contains 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 ObserverType { | |
typealias Element | |
func onNext(value: Self.Element) | |
func onError() | |
func onCompleted() | |
} | |
protocol ObservableType { | |
typealias Observer : ObserverType |
This file contains 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 Value: Equatable { | |
} | |
protocol Smashable { | |
typealias T: Value | |
func valueBySmashingOtherValue(value: T) -> T | |
} | |
struct Foo : Value, Smashable { | |
typealias T = Bar |
This file contains 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
extension UIView { | |
var firstSubview: UIView? { | |
if let firstSubview = self.subviews.first as? UIView { | |
assert(firstSubview != nil, "ASSERT COMPILATION ERROR") | |
return firstSubview | |
} else { | |
return nil | |
} | |
} | |
} |