- No return value parameter-free function class methods class name Function name calling
func1 FUNC static () { Print ( "None None Return Value parametric function func1") } ViewController.func1 ();
- No argument function has a return value func2
Print (func2 ()); FUNC func2 () -> String { return "parameter-free function returns a value func2" }
- No return value parameter function func3
func3 (one: "This is my own argument casually pass") FUNC func3 (One: String) { Print ( "there is no return value parameter function func3, parameters: \ (One)") }
- There are parameters, return values func4
print(func4(one: 1, tow: 2)); func func4(one: Int,tow: Int)->Int{ return one+tow; }
- Multi-parameter return func5
func func5(array: [Int])->(min: Int,max: Int){ if(array.isEmpty || array.count == 0 ) { return(-1,-1); } var min = array[0] var max = array[0] for value in array[1..<array.count] { if(value < min){ min = value; } if(value > max){ max = value; } } return (min,max); }
let bounds = func5(array: [6,2,7,9,4,21,243,62]); print("min:\(bounds.min) max:\(bounds.max)")
- Multi-parameter passed func6
func func6<N>(members: N...){ for i in members { print(i) } }
func6(members: 1,2,3); func6(members: 1);