jweinst1
6/1/2016 - 12:22 AM

allows you to store multiple types of closures in a dictionary and call them

allows you to store multiple types of closures in a dictionary and call them

let add = {(num:Int)->Int in num + 2}

let result = add is (Int)->Int
//true

var storage = [String:Any]()
storage["add"] = add
//can call stored closures from casting statement
(storage["add"]! as! (Int)->Int)(7)
//9