Created
October 15, 2017 05:22
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
// 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