Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Swift Album ver.4.1
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuka Ezura
December 18, 2017
Programming
1.6k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Swift Album ver.4.1
Yuka Ezura
December 18, 2017
More Decks by Yuka Ezura
See All by Yuka Ezura
Mastering share sheet preview
ezura
4
1.5k
SF Symbols
ezura
9
1.5k
気遣いの iOS プログラミング
ezura
11
3.8k
Secret Swift tour
ezura
7
3.1k
Swift と Kotlin
ezura
4
3k
哲学とSwiftの発表
ezura
5
650
アプリが動いたその先へ (iOS アプリ開発編)
ezura
1
1.2k
Blending Kotlin's culture into Swift
ezura
1
1.4k
Re: エラーと警告でコードをデザインする
ezura
2
1k
Other Decks in Programming
See All in Programming
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
210
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
290
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
360
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
170
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
140
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
360
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
200
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
140
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
11
5.9k
Featured
See All Featured
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
210
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Amusing Abliteration
ianozsvald
1
210
Test your architecture with Archunit
thirion
1
2.3k
Code Reviewing Like a Champion
maltzj
528
40k
Are puppies a ranking factor?
jonoalderson
1
3.6k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
240
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
560
Transcript
Swift Album ver.4.1
Swift
apple/swift
What’s happen in Swift4.1??
ezura • iOS engineer @ LINE • Advent calendar 2017
• Ͳ͏ͯͦ͠ͷػೳ/༷Swiftʹͳ͍ͷʁ • Swift4.1+ @eduraaa
ezura • iOS engineer @ LINE • Advent calendar 2017
• Ͳ͏ͯͦ͠ͷػೳ/༷Swiftʹͳ͍ͷʁ • Swift4.1+ @eduraaa
Topics • `Equatable`/`Hashable`ద߹ʹΑΔ`==`/`hashValue`ͷ҉త ࣮ • ಛఆͷ݅ԼͰͷϓϩτίϧద߹ • ࠶ىతͳϓϩτίϧ੍ • Unsafe[Mutable][Raw][Buffer]PointerͷAPIઃܭͷվળ
• ϓϩτίϧͰͷΦʔφʔγοϓͷએݴΛআ • Unsafe[Mutable][Raw][Buffer]PointerͷAPIઃܭͷվળ
Topics • `Equatable`/`Hashable`ద߹ʹΑΔ`==`/`hashValue`ͷ҉త ࣮ • ಛఆͷ݅ԼͰͷϓϩτίϧద߹ • ࠶ىతͳϓϩτίϧ੍ • Unsafe[Mutable][Raw][Buffer]PointerͷAPIઃܭͷվળ
• ϓϩτίϧͰͷΦʔφʔγοϓͷએݴΛআ • Unsafe[Mutable][Raw][Buffer]PointerͷAPIઃܭͷվળ
`==`/`hashValue`ͷ ҉త࣮
struct CustomType { let v1: String let v2: String let
v3: String } // CustomType instance == CustomType instance customInstance1 == customInstance2
struct CustomType { let v1: String let v2: String let
v3: String } // CustomType instance == CustomType instance customInstance1 == customInstance2 error: binary operator '==' cannot be applied to two 'CustomType' operands
struct CustomType: Equatable { let v1: String let v2: String
let v3: String static func ==(lhs: CustomType, rhs: CustomType) -> Bool { return lhs.v1 == rhs.v1 && lhs.v2 == rhs.v2 && lhs.v3 == rhs.v3 } } ໌ࣔతʹ࣮͢Δඞཁ͕͋ͬͨ
struct CustomType: Equatable { let v1: String let v2: String
let v3: String static func ==(lhs: CustomType, rhs: CustomType) -> Bool { return lhs.v1 == rhs.v1 && lhs.v2 == rhs.v2 && lhs.v3 == rhs.v3 } }
struct CustomType: Equatable { let v1: String let v2: String
let v3: String static func ==(lhs: CustomType, rhs: CustomType) -> Bool { return lhs.v1 == rhs.v1 && lhs.v2 == rhs.v2 && lhs.v3 == rhs.v3 } }
struct CustomType: Equatable { let v1: String let v2: String
let v3: String static func ==(lhs: CustomType, rhs: CustomType) -> Bool { return lhs.v1 == rhs.v1 && lhs.v2 == rhs.v2 && lhs.v3 == rhs.v3 } } ݅: શͯ `Equatable` ʹద߹ ݅: એݴ෦Ͱ `Equatable` ʹద߹
enum Token: Equatable { case string(String) case number(Int) case lparen
case rparen case custom(CustomType) static func == (lhs: Token, rhs: Token) -> Bool { switch (lhs, rhs) { case (.string(let lhsString), .string(let rhsString)): return lhsString == rhsString case (.number(let lhsNumber), .number(let rhsNumber)): return lhsNumber == rhsNumber case (.custom(let lhsCustom), .custom(let rhsCustom)): return lhsCustom == rhsCustom case (.lparen, .lparen), (.rparen, .rparen): return true default: return false } } }
enum Token: Equatable { case string(String) case number(Int) case lparen
case rparen case custom(CustomType) static func == (lhs: Token, rhs: Token) -> Bool { switch (lhs, rhs) { case (.string(let lhsString), .string(let rhsString)): return lhsString == rhsString case (.number(let lhsNumber), .number(let rhsNumber)): return lhsNumber == rhsNumber case (.lparen, .lparen), (.rparen, .rparen): return true case (.custom(let lhsCustom), .custom(let rhsCustom)): return lhsCustom == rhsCustom default: return false } } } ݅: શͯ `Equatable` ʹద߹ ݅: એݴ෦Ͱ `Equatable` ʹద߹
conditional conformance
protocol P {} struct S<T> {} extension S: P where
T: P {} ͱ͋Δ݅Λຬ͍ͨͯ͠Δ߹͚ͩ ܕʹ Protocol ͕ద߹͞ΕΔ
extension Array: Equatable where Element: Equatable { static func ==(lhs:
Array<Element>, rhs: Array<Element>) -> Bool { … } } `Element` ͕ `Equatable` ͷͱ͖ ͕ࣗ `Equatable` ʹద߹
ݱࡏ
extension Array: Equatable where Element: Equatable { static func ==(lhs:
Array<Element>, rhs: Array<Element>) -> Bool { … } } ॻ͚ͳ͍ʂ
Array<Equtable ద߹ͷܕ> == Array<Equtable ద߹ͷܕ> [1, 2, 3] ==
[1, 2, 3]
Array<Array<Equtable ద߹ͷܕ>> == Array<Array<Equtable ద߹ͷܕ>> [[1, 2, 3]] ==
[[1, 2, 3]]
Array<Array<Equtable ద߹ͷܕ>> == Array<Array<Equtable ద߹ͷܕ>> [[1, 2, 3]] ==
[[1, 2, 3]]
Array<Array<Equtable ద߹ͷܕ>> == Array<Array<Equtable ద߹ͷܕ>> [[1, 2, 3]] ==
[[1, 2, 3]] `==` ͰൺֱͰ͖Δ͚ΕͲ `Array` ࣗମ `Equatable` Ͱͳ͍
< Conditional conformances
extension Array: Equatable where Element: Equatable { static func ==(lhs:
Array<Element>, rhs: Array<Element>) -> Bool { … } } `Element` ͕ `Equatable` ͷͱ͖ ͕ࣗ `Equatable` ʹద߹
Array<Array<Equtable ద߹ͷܕ>> == Array<Array<Equtable ద߹ͷܕ>> [[1, 2, 3]] ==
[[1, 2, 3]] `Array` ࣗମ `Equatable`
ৄࡉͪ͜Β LINE Advent Calendar 2017 Swift 4.1+ https://engineering.linecorp.com/ja/blog/detail/227