μΌ | μ | ν | μ | λͺ© | κΈ | ν |
---|---|---|---|---|---|---|
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 |
29 | 30 | 31 |
- Filter
- mongoose
- Firestore
- μ§λ²λ³ν
- map
- nodejs
- νλ‘κ·Έλλ¨Έμ€
- components
- Codable
- Figma
- Encodable
- ExpressJS
- CRUD
- μκ³ λ¦¬μ¦
- μ±λ§λ€κΈ°
- String.Index
- Cloud Firestore
- Core Data
- Mac
- Firestore CRUD
- Decodable
- ios
- μ±λμμΈ
- Reduce
- DispatchQueue
- UIRefreshController
- RxSwift
- MongoDB
- SWiFT
- AVAudioPlayer
- Today
- Total
Focus On Develop π€π€
[Swift] Set λ³Έλ¬Έ
μμΈλ΄μ© : Set | Apple Document
κ·Έλ λ€κ³ νλ€.. Apple Developer Documenetλ μ½λ μ΅κ΄μ λ€μ΄λκ² μ€μνκΈ΄ νμ§λ§ μμ μμ΄λ μ΄λ ΅λ€ γ γ
μ€λλ λλ¦λλ‘ μμλ³Ό μ μλ λμ μΈμ΄λ‘ μ 리ν΄λ¬μΌκ² λ€.
Set(μ§ν©)μ Hashable νμ μ λ΄λ Collection μλ£κ΅¬μ‘° μ€ νλλ‘, μ€μ μνμμμ μ§ν©κ³Ό λΉμ·ν νΉμ§μ κ°λλ€.
"μμλ μ€μνμ§ μκ³ , μ€λ³΅κ°μ νμ©νμ§ μλ, Typeμ΄ κ°μ λ°μ΄ν°λ€μ λͺ¨μ"
κ·ΈλΌ Setμ μ΄λ»κ² μ°λμ§ λ³΄μ.
1. Set μμ±
var mySet = Set<String>()
var mySet2: Set<String> = []
2. Setμ λ°μ΄ν° μ½μ , μμ
var mySet: Set = ["my", "name", "is", "kt"] // Typeμ SetμΌλ‘ μ§μ νμ§ μμΌλ©΄ Arrayκ° λλ€.
mySet.insert("thanks") // ["my", "name", "thanks", "is", "kt"] - μμλ 보μ₯νμ§ μμΌλ©°
mySet.insert("my") // ["my", "name", "thanks", "is", "kt"] - μ€λ³΅μ νμ©νμ§ μλλ€.
mySet.remove("thanks") // ["kt", "my", "is", "name"]
3. Setμμ μμ£Ό μ¬μ©νλ κΈ°λ₯λ€
mySet.contains("kt") // true
mySet.isEmpty // false
mySet.count // 4
4. Setμμλ§ μ¬μ©κ°λ₯ν κΈ°λ₯λ€ (μ§ν©μ΄λΌμ μλ κΈ°λ₯λ€? μ λλ‘ ν΄μνλ©΄ λκ² λ€.)
var mySet: Set = ["my", "name", "is", "kt"]
var compareSet: Set = ["kt", "is", "iOS", "Developer"]
mySet.intersection(compareSet) // κ΅μ§ν© : ["is", "kt"]
mySet.symmetricDifference(compareSet) // ν©μ§ν©-κ΅μ§ν© : ["iOS", "Developer", "name", "my"]
mySet.union(compareSet) // ν©μ§ν© : ["my", "name", "is", "kt", "iOS", "Developer"]
mySet.subtracting(compareSet) // μ¬μ§ν© : ["my", "name"]
'iOS [Swift] > κΈ°μ΄λ₯Ό ννν!' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Swift] String.components (0) | 2020.12.18 |
---|---|
[Swift] String.Index (0) | 2020.12.17 |
[Swift] String Radixλ₯Ό ν΅ν μ§λ²λ³ν (0) | 2020.12.16 |
[Swift] enumerated() (0) | 2020.12.16 |
[Swift] map, filter, reduce (0) | 2020.12.15 |