Skip to content

Instantly share code, notes, and snippets.

@sgammon
Last active August 29, 2015 14:22
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 sgammon/18cc9e369f0145963253 to your computer and use it in GitHub Desktop.
Save sgammon/18cc9e369f0145963253 to your computer and use it in GitHub Desktop.
swanky closures and defaults
import UIKit
import Foundation
// how to make it
func timing(name: String, start: NSTimeInterval = NSDate().timeIntervalSince1970)() {
println("\(name): \(NSDate().timeIntervalSince1970 - start)")
}
// how to use it
let x = timing("sup")
x()
@sgammon
Copy link
Author

sgammon commented Jun 1, 2015

output:

sup: 0.004318[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment