Skip to content

Instantly share code, notes, and snippets.

@HamGuy
Forked from erica/with.swift
Created November 2, 2016 02:33
Show Gist options
  • Save HamGuy/fd139b7af9ac6b0a218f44ff969ff08f to your computer and use it in GitHub Desktop.
Save HamGuy/fd139b7af9ac6b0a218f44ff969ff08f to your computer and use it in GitHub Desktop.
// @discardableResult to be added
// @noescape needs to move to type annotation
// needs to add _ for item
public func with<T>(item: T, @noescape update: (inout T) throws -> Void) rethrows -> T {
var this = item; try update(&this); return this
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment