Skip to content

Instantly share code, notes, and snippets.

@tgnivekucn
Created August 22, 2018 13:28
Show Gist options
  • Save tgnivekucn/43275be033d20feb45f707aeb96f8da3 to your computer and use it in GitHub Desktop.
Save tgnivekucn/43275be033d20feb45f707aeb96f8da3 to your computer and use it in GitHub Desktop.
//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