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
typealias Generator<T> = (CIImage) -> T? | |
func outputCGImage<T: CGImage>(generator: Generator<T>) -> T? { | |
return filter.outputImage.flatMap(generator) | |
} | |
func outputUIImage<T: UIImage>(generator: Generator<T>) -> T? { | |
return filter.outputImage.flatMap(generator) | |
} |
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
var set: Set<Int> = [1,2,3,4] | |
func f1<T>(value: T, set: inout Set<T>) { | |
if set.contains(value) { | |
set.remove(value) | |
} else { | |
set.insert(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 UIKit | |
var json: String = """ | |
{ | |
"result": { | |
"persons": [ | |
{ |
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 f: ((Int, Int)) -> Void = { | |
print($0.0, $0.1) | |
} | |
let f1: ((Int, Int)) -> Void = { arg in | |
let (x, y) = arg | |
print(x, y) | |
} | |
let f2: ((Int, Int)) -> Void = { (arg: (x: Int, y: Int)) 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
struct ComposeTransformer<T, R> { | |
let transformer: (Observable<T>) -> Observable<R> | |
init(transformer: @escaping (Observable<T>) -> Observable<R>) { | |
self.transformer = transformer | |
} | |
func call(_ observable: Observable<T>) -> Observable<R> { | |
return transformer(observable) | |
} | |
} |
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
import Foundation | |
import RxSwift | |
import Firebase | |
extension FIRAuth { | |
public enum AuthProvider { | |
case emailPassword(String, String) | |
case facebook(String) | |
case google(String, String) | |
case twitter(String, String) |
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
import PlaygroundSupport | |
import Foundation | |
let me: String?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? |
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 Baz: NSObject { | |
dynamic var value: String = "" | |
override class func automaticallyNotifiesObservers(forKey key: String) -> Bool { | |
if key == "value" { | |
return true | |
} | |
return super.automaticallyNotifiesObservers(forKey: key) | |
} |
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 Hoge { | |
var a: String? { | |
didSet { | |
b = a | |
} | |
} | |
var b: String? | |
deinit { | |
print("\(#function)") |
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
indirect enum LinkedListNode<T> { | |
case value(element: T, next: LinkedListNode<T>) | |
case end | |
} | |
extension LinkedListNode: Sequence { | |
func makeIterator() -> LinkedListIterator<T> { | |
return LinkedListIterator(self) | |
} | |
} |