7
9

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.

Swift 多次元配列の宣言、追加、削除について 備忘録

Posted at

こんにちは、今回は多次元配列について記事が少なくつまずいたので備忘録として記事にしました。
Xcode Version 11.3
Swift Version 5.1.3

Array.swift
//多次元配列

//宣言
var array:[[String]] = [] // >>> array = []
var hoge:[[String]] = [["こんにちは"],["Hello","Study"]] // >>> hoge = [["こんにちは"],["Hello","Study"]]

//追加
array.append([]) // >>> array = [[]]
array[0].append("こんばんわ") // >>> array = [["こんばんわ"]]

//削除
hoge[1].remove(at:0) // >>> hoge = [["こんにちは"],["Study"]]
hoge.remove(at:0) // >>> hoge = [["Study"]]
7
9
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
7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?