LoginSignup
1
2

More than 5 years have passed since last update.

関数の例(戻り値、引数)

Posted at
override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        showMessage(name: "太郎", age: 10)
        let name = getName()
        print(name) //太郎

    }

    func hogehoge3 (_ plusScore: Int) {
        let baseScore = 10
        let totalScore = baseScore + plusScore
        print(totalScore)
    }

    func hogehoge (_ array: [String]) {
        print(array)
    }


    func hogehoge2 (array: [String]) {
        print(array)
    }


    //戻り値がある関数
    func getName () -> String {
        let name = "太郎"
        return name
    }


    func showMessage (name: String, age: Int) {
        print("私の名前は\(name)です。年齢は\(age)才です")

    }
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2