0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

外部引数名の省略

Posted at

外部引数名を省略したい場合は、外部引数名にアンダースコアをつけることで省略できます。

func sum(_ x: Int, _ y: Int) {
        return x + y
}

sum(1, 3) //出力: 4

省略しない通常の書き方だと

sum(x: 1, y: 3)

と書く必要があるので、省略できた方がコードがシンプルになりますね。

参考

[増補改訂第3版]Swift実践入門 ── 直感的な文法と安全性を兼ね備えた言語 (WEB+DB PRESS plusシリーズ)

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?