Last active
September 27, 2016 18:54
-
-
Save erica/1bb492d616370c5e8ae3383b140c41b4 to your computer and use it in GitHub Desktop.
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
% ed test.swift | |
test.swift: No such file or directory | |
a | |
import Foundation | |
public func with<T: AnyObject>(_ item: T, update: (inout T) throws -> Void) rethrows -> T { | |
var this = item | |
try update(&this) | |
var ptr: Unmanaged<T>? = Unmanaged<T>.passRetained(this).autorelease(); defer { ptr = nil } | |
return this | |
} | |
let p = Process() | |
let task3 = with(p) { | |
$0.launchPath = "/usr/bin/mdfind" | |
$0.arguments = ["kMDItemDisplayName == *.playground"] | |
$0.standardOutput = pipe | |
} | |
let task4 = with(Process()) { | |
$0.launchPath = "/usr/bin/mdfind" | |
$0.arguments = ["kMDItemDisplayName == *.playground"] | |
$0.standardOutput = pipe | |
} | |
print(task3) | |
print(task4) | |
. | |
w | |
618 | |
q | |
% swiftc test.swift | |
% ./test | |
<NSConcreteTask: 0x7fca1240b200> | |
<NSConcreteTask: 0x7fca1240d4f0> | |
% swift test.swift | |
<NSConcreteTask: 0x7fbed9f26130> | |
<NSConcreteTask: 0x7fbed9f307c0> | |
% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment