1 return func pointer(address)
func getFuncPointer()->(Int->Int){
func add(num:Int)->Int{
return num+1;
}
return add;
}
var f = getFuncPointer();
println(f(100))
2 function pointer(address) as the parameter of function
func lessThanTen(num:Int)->Bool{
return num < 10;
}
func hasAnyMatch(list:[Int],condition:Int->Bool)->Bool{
for item in list{
if condition(item){
return true
}
}
return false
}
var B:Bool = hasAnyMatch(arr,lessThanTen);
println(B)