//无返回值函数
func noneRetValue ()
{
print(“hello”)
}
//多返回值函数
func muliptyV (fruit: String) ->(a:Int,b:Int,c:Int){
var vol = 0
var voc = 0
var vob = 0
for c in fruit.characters {
switch c {
case "a","e","i","o","u":
vol += 1
case "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z" : voc += 1
default: vob += 1
}
}
return(vol,voc,vob)
}
//获取多返回值中的指定值;;;
let haha = muliptyV(fruit: “abc”)
print(haha.a)
print(haha.b)
//返回值可以忽略不计,但对一个函数来说,它的返回值即便不使用还是一定会返回的
// 无参函数
func noneparm () -> String
{
return “Hello World”
}
//1. 单一参数函数
//函数的写法 参数类型 -> 返回值类型
func sayHello (personName :String) ->String{
let greeting = “Hello” + personName + “!”
return greeting
}
//函数调用.
print(sayHello(personName: “133谁吖”))
//2.多输入参数函数
func halfO(start:Int,end:Int) -> Int{
let temp = start + end
return temp
}
print(halfO(start: 1, end: 5))