func play1(param1:String,param2:(String) ->Void)
{
param2(param1 + "---swift")
}
//play1(param1: "hello", param2: {(data:String) -> Void in
// print(data)
//})
play1(param1: "world") { (data) in
print(data)
}
func play2(param:(String) -> String)
{
var value = param("swift")
print("返回值:\(value)")
}
//play2(param: {(data) -> String in
//
// return data + "--ios"
//})
play2 { (data) -> String in
return data+"---ios1"
}
func play3(parm:() -> Void)
{
parm()
}
play3(parm:{
print("play3")
})
play3(){
print("play3")
}
play3 {
print("play3")
}
func play4(param:() -> String)
{
var value = param()
print("value =\(value)")
}
play4(param: {()->String in
return " hello"
})
play4(){() -> String in
return "hello world"
}
play4 { () -> String in
return " play4 ---"
}
play4{
return " dsds"
}
func play5(param1:(Int) -> Void, param2:Int)
{
param1(param2 * 2)
}
play5(param1: {(data:Int) -> Void in
print(data)
}, param2: 100)
play5(param1: {(data) in
print(data)
}, param2: 100)
网友评论