Created
August 22, 2018 13:28
-
-
Save tgnivekucn/43275be033d20feb45f707aeb96f8da3 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
//ex: 比較 a,b大小 | |
var a = 54 | |
var b = 5 | |
//用function: | |
func compare(val1: Int,val2: Int) -> Bool { | |
return a > b | |
} | |
assert(compare(val1:a,val2:b), "error, a can not larger than b") | |
//用closure: | |
assert(a > b, "error, a can not larger than b") //note: a > b 即為closure,其省略了參數和回傳值 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment