前端之家收集整理的这篇文章主要介绍了
swift (三),
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
func printString() {
println("Hello World!")
}
func printString2()->() {
println("Hello World!")
}
printString()
func returnHello()->String {
return "hello"
}
println(returnHello())
func personHello(str:String) {
println("str = \(str)")
}
personHello("wzgwzg")
func personHello(str:String)->String {
return str + "hello"
}
println((personHello("gzwgzw")))
func personHello(str1:String,str2:String)->(string1:String,string2:String) {
var minValue = str1.lowercaseString ;
var maxValue = str2.uppercaseString ;
return (minValue,maxValue)
}
println((personHello("WANG","zhen")))
func changeValueInfunc(var number:Int)->Int {
number++
return number
}
println((changeValueInfunc(9)))
func swapTwoNumber(inout number1:Int,inout number2:Int) {
var temp = 0
temp = number1
number1 = number2
number2 = temp
}
var aaa = 10,bbb = 23
swapTwoNumber(&aaa,&bbb)
println("a = \(aaa),b = \(bbb)")
func printPersonName(personName str:String) {
println( str )
}
printPersonName(personName: "wangzhengang")
func printPersonName2(#personName:String) {
println(personName)
}
printPersonName2(personName: "wangzhengang")
func funcType(number:Int)->Int {
return number
}
var houFunc:(Int)->Int = funcType
println(houFunc(5))