Skip to content

Instantly share code, notes, and snippets.

@erica
Last active September 27, 2016 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erica/1bb492d616370c5e8ae3383b140c41b4 to your computer and use it in GitHub Desktop.
Save erica/1bb492d616370c5e8ae3383b140c41b4 to your computer and use it in GitHub Desktop.
% 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