Skip to content

Instantly share code, notes, and snippets.

@xuanvinhtd
Created October 15, 2017 05:22
// Một closure có đối số kiểu Int và kiểu trả về là Int
var double: (Int) -> (Int) = { x in
return 2 * x
}
double(2) // 4
// Gán closure cho một biến khác và xữ lý của biến alsoDouble cũng tương tự double.
var alsoDouble = double
alsoDouble(3) // 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment