Skip to content

Instantly share code, notes, and snippets.

enum Either<A, B> {
case Left(A)
case Right(B)
}
func isLeft<A,B>(it : Either<A,B>) -> Bool {
switch it { case .Left: return true; case .Right: return false }
}
func isRight<A,B>(it : Either<A,B>) -> Bool {
Note that like all analogies, this is not a perfect one. I find it helps me think about it though. Also, don't try to draw conclusions about performance from this analogy :)
-[NSUserDefaults setObject:forKey:] is like...
<edit file to add key and value>
git add file
git commit
dispatch_after(some time, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[NSUserDefaults standardUserDefaults] synchronize]
});