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
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
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
120
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
Contextとはなにか
chiroruxx
1
370
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
180
Oxlintのカスタムルールの現況
syumai
6
1.1k
スマートグラスで並列バイブコーディング
hyshu
0
260
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
800
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
130
dRuby over BLE
makicamel
2
390
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
180
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
800
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
330
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Ethics towards AI in product and experience design
skipperchong
2
310
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
The agentic SEO stack - context over prompts
schlessera
0
820
Faster Mobile Websites
deanohume
310
32k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Exploring anti-patterns in Rails
aemeredith
3
420
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
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