美文网首页
swift 4.0 函数

swift 4.0 函数

作者: 透支未来 | 来源:发表于2018-01-26 10:08 被阅读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.
    }
}

相关文章

网友评论

      本文标题:swift 4.0 函数

      本文链接:https://www.haomeiwen.com/subject/wxeiaxtx.html