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.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
1.1k
Other Decks in Programming
See All in Programming
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
160
OSINT for SRE: 学術論文とポストモーテムから探る システム障害の共通パターン / SRE NEXT 2026
tomoyk
1
3.4k
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
210
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.4k
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
350
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
190
AIエージェントで 変わるAndroid開発環境
takahirom
2
500
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.3k
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
170
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
100
Webフレームワークの ベンチマークについて
yusukebe
0
200
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Code Review Best Practice
trishagee
74
20k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
220
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
230
The Cult of Friendly URLs
andyhume
79
6.9k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
220
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Code Reviewing Like a Champion
maltzj
528
40k
sira's awesome portfolio website redesign presentation
elsirapls
0
300
Optimizing for Happiness
mojombo
378
71k
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