반응형
배열(Array)
배열의 축약형 문법
배열 타입은 Array로 적을 수 있는데 축약형으로 [Element] 형태로 사용할 수도 있습니다.
빈 배열의 생성
아래와 같이 Int형 빈 배열을 생성할 수 있습니다.
var someInts = [Int]()
print("someInts is of type [Int] with \(someInts.count) items.")
// someInts is of type [Int] with 0 items.
print("someInts is of type [Int] with \(someInts.count) items.")
// someInts is of type [Int] with 0 items.
someInts.append(3)
// 배열에 3을 추가 했습니다.
someInts = []
// 배열을 비웠습니다. 배열의 아이템 타입은 그대로 Int로 유지됩니다.
// 배열에 3을 추가 했습니다.
someInts = []
// 배열을 비웠습니다. 배열의 아이템 타입은 그대로 Int로 유지됩니다.
반응형
'개발 > iOS' 카테고리의 다른 글
Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5 (0) | 2023.07.27 |
---|---|
Swift 제어문 (Control Flow) (0) | 2023.02.17 |
Swift 단항 양수 연산자(Unary Plus Operator) (0) | 2023.02.14 |
Swift 단항 음수 연산자(Unary Minus Operator) (0) | 2023.02.14 |
[Xcode] Provisioning Profiles 삭제 (프로비저닝 프로파일 삭제) (0) | 2023.02.13 |