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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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.4k
気遣いの iOS プログラミング
ezura
11
3.7k
Secret Swift tour
ezura
7
3k
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
JavaDoc 再入門
nagise
0
290
Oxcを導入して開発体験が向上した話
yug1224
4
290
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.5k
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
310
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
550
LLM Plugin for Node-REDの利用方法と開発について
404background
0
160
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
17
6.1k
AI時代のUIはどこへ行く?その2!
yusukebe
19
6.7k
Agentic UI
manfredsteyer
PRO
0
110
dRuby over BLE
makicamel
2
320
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
230
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
3.1k
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
3.1k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
150
30 Presentation Tips
portentint
PRO
1
320
How STYLIGHT went responsive
nonsquared
100
6.2k
How to Talk to Developers About Accessibility
jct
2
220
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
150
Writing Fast Ruby
sferik
630
63k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
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