swift4.0 下划线 "_"

  override func touchesBegan(_ touches: Set, with event: UIEvent?) {

        funcOne(name: "will", age: 29)
        funcTwo("lily", 20)

    }

    //未使用下划线忽略外部名
    @objc func funcOne(name:String,age:Int = 20){
        
        print("one:name = \(name),age = \(age)")
        
    }
    //使用下划线忽略外部名
    @objc func funcTwo(_ name:String,_ age:Int = 20){
        print("two:name = \(name),age = \(age)")
        
    }

打印结果:

one:name = will, age = 29
two:name = lily, age = 20

你可能感兴趣的:(swift4.0 下划线 "_")