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
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
410
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
net-httpのHTTP/2対応について
naruse
0
500
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
350
Oxlintのカスタムルールの現況
syumai
6
1.1k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
880
A2UI という光を覗いてみる
satohjohn
1
140
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
120
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
260
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
360
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
200
Featured
See All Featured
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
860
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
220
Everyday Curiosity
cassininazir
0
230
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
460
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
150
ラッコキーワード サービス紹介資料
rakko
1
3.7M
Designing Powerful Visuals for Engaging Learning
tmiket
1
420
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
エンジニアに許された特別な時間の終わり
watany
107
250k
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