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
/// Lesson learned: | |
/// Inside a throwing function... | |
/// if a `guard` condition calls a second function that ends up throwing... | |
/// the second function's error is immediately propagated outside of the function. | |
/// Execution does not enter the `else` block of the `guard` clause. | |
struct PlaygroundError: Error { | |
let message: 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 <Foundation/Foundation.h> | |
#define SAMPLE @"one sample string value" | |
NSString *addressOf(id object) { | |
return [NSString stringWithFormat:@"%p", object]; | |
} | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { |
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 XCTest | |
public func runTests(inClass testClass: XCTestCase.Type) { | |
let testSuite = testClass.defaultTestSuite | |
testSuite.run() | |
guard let testRun = testSuite.testRun else { | |
preconditionFailure("Couldn't run tests in \(testClass)") | |
} | |
let failCount = testRun.totalFailureCount | |
guard failCount == 0 else { |
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.m | |
// ArrayInitialization | |
// | |
// Created by Anson Jablinski on 5/2/16. | |
// Copyright © 2016 ForeFlight. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
// Runs in a Playground | |
func repeat(function: () -> (), untilNoChangeTo sentinel: () -> String) { | |
var initial, final: String | |
do { | |
initial = sentinel() | |
function() | |
final = sentinel() | |
} while initial != final |