์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- node.js
- reactorkit
- TCA
- MVVM
- ๋ฐฑ์ค
- Xcode
- visionOS
- Swfit
- BOJ
- raywenderlich
- rxcocoa
- CollectionView
- realm
- RxSwift
- XCTest
- arkit
- SwiftUI
- UIKit
- ํจ์คํธ์บ ํผ์ค
- BFS
- designpattern
- swift
- ํ๋ก๊ทธ๋๋จธ์ค
- ios
- Lv2
- combine
- tableView
- SnapKit
- Flutter
- Kuring
- Today
- Total
lgvv98
๐ ch13 swift Equatable?! ๋ณธ๋ฌธ
๐ ch13 swift Equatable?!
๐ฅ ์บ๋ฟ๋งจ 2021. 6. 25. 22:41โ ์ด๋ฒ ์๊ฐ์๋ Equtable์ ๋ํด์ ์์๋ณด๋๋ก ํ ๊ฒ.
Equatable์ด ๋ญ๋?
๋ ๊ฐ์ด ๋์ผํ์ง ํ์ธํ ์ ์๋ ํ๋กํ ์ฝ์ด์ผ.
์ฐ๋ฆฌ๊ฐ ์ฝ๋ฉ์ ํ๋ฉด์ "abc" == "abc" ํน์ 33 != 33 ๋ฑ ์ค์ํํธ์ ๊ธฐ๋ณธ ํ์ ์ ๊ฐ์์ง ๋ค๋ฅธ์ง ๋น๊ตํด๋ณธ์ ์ด ์์์ง?
๋๋ฌด ๋จ์ํ๊ฒ ๊ทธ๋ฅ ๋น๊ตํ๋ฉด ๋๋๊ฑฐ ์๋๊ฐ..? ์ผ๋ ๊ฒ๋ค์ธ๋ฐ,,
์ฐ๋ฆฌ๋ ์ด๋ฌํ ๋ฌธ์ ์ ๋ถ๋ชํ๊ฒ ๋ผ
๊ทธ๋ผ swift์์ ๊ตฌ์กฐ์ฒด๋ ํด๋์ค์ ์ธ์คํด์ค๋ค์ ๊ฐ์ด ๊ฐ์์ง๋ ์ด๋ป๊ฒ ๋น๊ตํ ์ ์์๊น?
์๋์ ์์๋ฅผ ํ๋ฒ ๋ด๋ณด์.
class A{
var aNum : Int
init(_ aNum :Int) {
self.aNum = aNum
}
}
if A(1) == A(2) //error!
{
}
์ถ์ฒ: https://zeddios.tistory.com/227 [ZeddiOS]
์๋ฌ๊ฐ ๋ฐ์ํ๋ค๊ณ ํ๋ค!
๊ทธ๋ฌ๋ฉด ์ฐ๋ฆฌ๋ Equtable์ ์์ ๋ฐ์์ ์ฌ์ฉํด์ผ ํ๋๋ฐ, ์ฌ๊ธฐ์๋
static func == (lhs: Self, rhs: Self) -> Bool {
return true
}
๋ฉ์๋๊ฐ ํ๋กํ ์ฝ๋ก ์ ์๋์ด ์์ด.
์ฌ๊ธฐ ์์ ์ ์ํด์ ์ฌ์ฉํ๋ฉด ๋ผ
- ์ฐธ๊ณ
https://zeddios.tistory.com/227
Swift ) Equatable
์๋ ํ์ธ์ :) Zedd์ ๋๋ค. ์ค๋์ Swift์ Equatable์ ๋ํด์ ์์๋ณผ๊ฑฐ์์ XD ์ ๋ ์ฒ์๋ค์ด๋ณธ๋ต๋๋ค... ๋ค์๊ธ์์ Equatable์ด ๋์ค๋๋ฐ Equatable์ ๋ชจ๋ฅด์๋ ๋ถ๋ค์ ์ํด(+๋) ์ ๋ฆฌํด๋ณด๋ ค๊ณ ํด์ :)
zeddios.tistory.com
https://developer.apple.com/documentation/swift/equatable
Apple Developer Documentation
developer.apple.com
http://seorenn.blogspot.com/2014/08/swift-equatable-comparable-printable.html
Swift์ ๊ธฐ๋ณธ ํ๋กํ ์ฝ ์ธ ๊ฐ์ง: Equatable, Comparable, Printable
iOS ๋ฐ macOS ์ฉ ์ฑ ๊ฐ๋ฐ, Emacs, Vim, Python ์์ฃผ๋ก ๋ค๋ฃจ๋ Seorenn ๊ฐ์ธ ๋ธ๋ก๊ทธ
seorenn.blogspot.com
'โ ๏ธ deprecated โ ๏ธ > ํจ์บ (์ฌ์ธ์)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
โจ๏ธ ch13 ํค๋ณด๋์ ๋ฐ๋ฅธ ๋ ์ด์์ ์กฐ์ ํ๊ธฐ (0) | 2021.06.26 |
---|---|
๐คช ch13 ๋ฒํผ ์ํ์ ๋ฐ๋ผ ๋ฐ๊ฟ์ฃผ๊ธฐ (0) | 2021.06.26 |
๐ฆง ch13 Static Cell (TableView) (0) | 2021.06.25 |
ch12 ์ ํ๋ฎค์งst ์์ ์ฑ ์ฝ๋๋ฆฌ๋ทฐ (0) | 2021.06.24 |
๐ ch11 ํ์๊ธ ๋ญํน์ฑ ์ฝ๋๋ฆฌ๋ทฐ(Animation)๐ (0) | 2021.06.22 |