swift 4.0 函数

2018-01-26  本文已影响32人  透支未来

函数

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
//        print(firstFuns("小明", "18"))
        print(firstFuns())
        print(firstFuns(name: "小明", age: "30"))
        print(firstFuns(name: "小仙女"))
        // Do any additional setup after loading the view, typically from a nib.
    }

    //创建有参有返回的方法
    func firstFuns(name:String = "小霞霞",age:String = "18") -> String {
        return name + age
    }
    func firstFuns(_ name:String,_ age:String) -> String {
        return name + age
    }
    func firstFuns(Str1 name:String,Str2 age:String) -> String {
        return name + age
    }
    
    
    //函数的无返回值形式
    func demo() {
        
    }
    func demo1() -> () {
        
    }
    func demo2() -> Void {
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

上一篇 下一篇

猜你喜欢

热点阅读