This file contains hidden or 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 CoreData |
This file contains hidden or 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 ReactiveCocoa | |
| import Orcinus |
This file contains hidden or 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 | |
| enum JSONError : ErrorType { | |
| case NoValueForKey(String) | |
| case TypeMismatch | |
| } | |
| public class JSONObject { |
This file contains hidden or 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 | |
| enum JSONError : ErrorType { | |
| case NoValueForKey(String) | |
| case TypeMismatch | |
| } | |
| public class JSONObject { |
This file contains hidden or 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 | |
| struct Address { | |
| var street: String | |
| } | |
| struct Person { | |
| var name: String |
This file contains hidden or 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 Dictionary { | |
| mutating func update(key: Key, initial: Value, update:Value->Value) { | |
| if let x = self[key] { | |
| self[key] = update(x) | |
| } | |
| else { | |
| self[key] = initial | |
| } | |
| } | |
| } |
This file contains hidden or 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 :timer, only: [sleep: 1] | |
| defmodule TickerNode do | |
| @interval 2000 # 2 seconds | |
| @name :ticker | |
| def start do | |
| pid = spawn(__MODULE__, :run, [nil, nil]) | |
| if :global.whereis_name(@name) == :undefined do | |
| IO.puts "Spawning as root node" |
This file contains hidden or 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
| public protocol Section { | |
| typealias U | |
| var count: Int { get } | |
| func itemAtRow(row: Int) -> U | |
| subscript(index: Int) -> U { get } | |
| } | |
| public struct ArraySection<T>: Section { | |
| typealias U = T | |
This file contains hidden or 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
| func expect<T: Equatable>(value: T, file: String = __FILE__, line: Int = __LINE__) -> (T, String, Int) { | |
| return (value, file, line) | |
| } | |
| func ==<T: Equatable>(lhs: (T, String, Int), rhs: T) { | |
| if lhs.0 != rhs { | |
| XCTFail("Expected \(rhs), but got \(lhs.0) instead", file: lhs.1, line: UInt(lhs.2)) | |
| } | |
| } |
This file contains hidden or 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
| Pkg.add("Gadfly") | |
| using Gadfly | |
| # Random cool meta stuff | |
| print(code_typed(print, ())) | |
| :(2 + 2) # quote expressions to see AST | |
| print(code_lowered(print, ())) # see the lowered AST | |
| # returns an array because some functions return multiple values | |
| Pkg.add("Cairo") |