この文書の現在のバージョンと選択したバージョンの差分を表示します。
| 両方とも前のリビジョン 前のリビジョン | |||
|
kotlin:kotlinコードサンプル [2019/09/01 01:27] ips |
kotlin:kotlinコードサンプル [2019/09/01 16:06] (現在) ips |
||
|---|---|---|---|
| ライン 177: | ライン 177: | ||
| </code> | </code> | ||
| + | |||
| + | ===== list ===== | ||
| + | |||
| + | [[https://qiita.com/kiririnyo/items/aee905225902d096f7c0|Kotlin の Collection まとめ ~List編~]] | ||
| + | [[https://qiita.com/opengl-8080/items/36351dca891b6d9c9687|Kotlin のコレクション使い方メモ]] | ||
| + | |||
| + | 不変のリストは listOf | ||
| + | 可変のリストは mutableListOf | ||
| + | 文字列の結合joinToString | ||
| + | |||
| + | |||
| + | <code> | ||
| + | fun joinOptions(options: Collection<String>) = options.joinToString(prefix = "[", postfix = "]") | ||
| + | |||
| + | fun main() { | ||
| + | val list = listOf("t", "e", "s", "t") | ||
| + | println(joinOptions(list)) | ||
| + | |||
| + | } | ||
| + | ↓ | ||
| + | [t, e, s, t] | ||
| + | </code> | ||