티스토리 뷰
var arr001 = ["100", "200"]
var arr002 = Array<String>()
arr002.append("100")
arr002.append("200")
var isSame : Bool = arr001 == arr002
print("isSame = \(isSame)") // result : isSame = true
var strArr = Array<String>()
strArr.append("a")
strArr.append("b")
strArr.append("c")
print(strArr) // result : ["a", "b", "c"]
print(strArr.count) // result : 3
strArr.append(contentsOf: ["d", "e"])
print(strArr) // result : ["a", "b", "c", "d", "e"]
strArr += ["f", "g"]
print(strArr) // result : ["a", "b", "c", "d", "e", "f", "g"]
strArr.removeFirst()
print(strArr) // result : ["b", "c", "d", "e", "f", "g"]
strArr.removeLast()
print(strArr) // result : ["b", "c", "d", "e", "f"]
strArr.insert("a", at: 0)
print(strArr) // result : ["a", "b", "c", "d", "e", "f"]
for element in strArr {
print("element : \(element)")
}
/*
result :
element : a
element : b
element : c
element : d
element : e
element : f
*/
// how to prevent index out of range
let index = 2
if strArr.count > index {
print(strArr[index])
} // result : c
'ios' 카테고리의 다른 글
for - string (0) | 2022.05.20 |
---|---|
while (0) | 2022.05.20 |
set (0) | 2022.05.19 |
guard (0) | 2022.05.19 |
dictionary (0) | 2022.05.19 |
- Total
- Today
- Yesterday
- defaultInputmode
- logcat
- 안드로이드
- 영문 키보드
- logtag
- create project
- 로그캣
- Inputmode
- permissions
- web view
- web view settings
- check permissions
- 외부 브라우저
- kotlin
- 클래스 이름
- web chrome view
- custom web view
- javaClass
- 웹뷰
- 화면 고정
- simpleName
- Android
- 코틀린
- screenorientation
- android studio
- 화면 방향 고정
- StringWriter
- new project
- andorid
- create new project
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |