Created
January 31, 2015 14:16
-
-
Save nuclearace/2d4ec6ede4a89565d846 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
import Foundation | |
typealias NormalCallback = (AnyObject?) -> Void | |
typealias MultipleCallback = (AnyObject?...) -> Void | |
func on(callback:NormalCallback) { | |
callback(1) | |
} | |
func onMultiple(callback:MultipleCallback) { | |
callback(0, 1, 2) | |
} | |
on {println($0)} | |
onMultiple {data in | |
for item in data { | |
println(item) | |
} | |
} | |
// What I wish I could do | |
// func on(callback:MultipleCallback) { | |
// callback(0, 1, 2) | |
// } | |
// | |
// on {data1, data2, data3 in | |
// | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment