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
Voidと() - 意図を伝える“ユニット型”の世界- / Void vs () -The W...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
marcy731
September 30, 2025
19
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Voidと() - 意図を伝える“ユニット型”の世界- / Void vs () -The World of Expressing Intent
2025.09.30 チキチキ!モバイルLT大会 〜残暑編〜
marcy731
September 30, 2025
More Decks by marcy731
See All by marcy731
沈黙すべきか、叫ぶべきか - 独自ブラウザの GPC 実装 - / gpc-war-story
marcy731
0
18
WebViewの現在地 - SwiftUI時代のWebKit - / The Current State Of WebView
marcy731
0
310
めざせ!WKWebViewマスター! / WKWebView Master
marcy731
4
3.3k
GitHub Copilotのススメ
marcy731
1
1.4k
Introduction to Memory Management in Swift - Swiftのメモリ管理を知る -
marcy731
0
39
ステートマシンを活用したWebView-ネイティブ間連携へのアプローチ / An Approach to WebView-Native Communication Using State Machines
marcy731
1
1.7k
WebViewをNativeのように使いたい / Using-WebView-like-Native-App
marcy731
2
640
「アプリをつくる仕組み」の構築 / build-system-for-STORES-Branded-Apps
marcy731
0
860
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
From π to Pie charts
rasagy
0
210
The SEO identity crisis: Don't let AI make you average
varn
0
490
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Tell your own story through comics
letsgokoyo
1
960
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
200
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
400
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
260
Designing for Timeless Needs
cassininazir
1
260
Bash Introduction
62gerente
615
220k
We Are The Robots
honzajavorek
0
250
Transcript
Voidͱ() - ҙਤΛ͑Δ“Ϣχοτܕ”ͷੈք- STORESגࣜձࣾ ϞόΠϧ։ൃຊ෦ Ϛωʔδϟʔ/iOSΤϯδχΞ ୩ ক࢘ʢ@marcy731ʣ 2025.09.30 νΩνΩʂϞόΠϧLTେձ
ʙॵฤʙ
Void
None
None
None
public typealias Void = ()
Void () ͷܕΤΠϦΞε public typealias Void = ()
()
() : “ۭͷλϓϧ”
() : “Empty Tuple”
Tuple • ෳͷΛͻͱ·ͱΊʹͰ͖Δߏ • ܕͱͯ͠ʮҟͳΔܕΛͻͱͭʹଋͶͨ߹ܕ (product type)ʯ
let tuple1: (Int, String) = (42, “hello") let tuple2: (id:
Int, name: String) = (id: 1, name: "Alice") ཁૉʹॱং͕͋Γɺ0͔ΒͷΠϯσοΫεϥϕϧͰΞΫηεͰ͖Δ Tuple
let tuple1: (Int, String) = (42, “hello") let tuple2: (id:
Int, name: String) = (id: 1, name: "Alice") ϥϕϧΛ͚ΕʮߏମʯͬΆ͘ѻ͑Δ Tuple
0ཁૉλϓϧ: () → ۭλϓϧɺ།Ұͷ͔͠ͳ͍ → Ϣχοτܕ 1ཁૉλϓϧ: ଘࡏ͠ͳ͍ʢ(Int) = Int
ʹ௵ΕΔʣ 2ཁૉҎ্λϓϧ: (A, B, ...) ͱͯ͠ී௨ʹ͑Δ λϓϧͷཁૉ͝ͱͷಛҟੑ
0ཁૉλϓϧ: () → ۭλϓϧɺ།Ұͷ͔͠ͳ͍ → Ϣχοτܕ 1ཁૉλϓϧ: ଘࡏ͠ͳ͍ʢ(Int) = Int
ʹ௵ΕΔʣ 2ཁૉҎ্λϓϧ: (A, B, ...) ͱͯ͠ී௨ʹ͑Δ λϓϧͷཁૉ͝ͱͷಛҟੑ Void
public typealias Void = ()
public typealias Void = () Ϣχοτܕͱͯ͠ͷ ()
ΫϩʔδϟͰͷҙਤදݱ let f: () -> Void = { } let
g: () -> () = { }
ΫϩʔδϟͰͷҙਤදݱ let f: () -> Void = { } let
g: () -> () = { } ܕγεςϜ্·ͬͨ͘ಉ͡ܕɻ ݺͼग़͠ํɾಈ࡞ʹҧ͍ͳ͍ɻ
ΫϩʔδϟͰͷҙਤදݱ let f: () -> Void = { } let
g: () -> () = { } ͰχϡΞϯεҧ͏ɻ
() -> Void let f: () -> Void = {
} • ҙຯ߹͍: ʮ෭࡞༻͚ͩΛߦ͍ɺΓͳ͍ʯ • ϝϦοτ: • ׳शతʹ࠷͘ΘΕ͍ͯΔ • ඪ४ϥΠϒϥϦެࣜυΩϡϝϯτͰͪ͜Β͕جຊ • ʮฦ͢ͳ͍ʯͱ͍͏ҙਤ͕ଈΘΔʢಡΈ͍͢ʣ • ࣮తഎܠ: • νʔϜશମͰಡΜͩͱ͖ʹ Ұ؏ੑ͕͋Δ • ެࣜʹ฿͏ͷ͕ʮSwiftyʯͳॻ͖ํ • ܕͷཪଆʢۭλϓϧͷਖ਼ମʣΛҙࣝ͠ͳͯ͘Α͍ͨΊɺແବʹಡऀΛ໎Θͤͳ͍
() -> () let g: () -> () = {
} • ҙຯ߹͍: ʮۭλϓϧʢ།ҰͷʣΛฦ͢ʯ͜ͱΛ ͋Γͷ··ॻ͍ͨܗ • ϝϦοτ: • ܕཧʹ͍ۙදهͰɺਖ਼͕֬͋͞Δ • σϝϦοτ: • ࣮Ͱ΄ͱΜͲݟ͔͚ͳ͍ → ಡΈख͕ʮͳΜͰͬͪ͜ʹͨ͠ΜͩΖ͏ʁʯͱҰॠ ߟ͑Δ • Ұൠతͳ Swift ίʔυελΠϧ͔Β֎ΕΔ → ʮSwifty ͡Όͳ͍ʯͱײ͡ΒΕ͍͢
APIઃܭͰͷ׆༻ 1. Result<Void, Error> 2. Optional<Void> 3. Reactive / Combine
Result<Void, Error> ʮޭ͕ͩฦ͢ͳ͍ʯ func save(document: Data) async -> Result<Void, SaveError>
{ // ... do work guard hasSpace else { return .failure(.diskFull) } // อଘޭɻฦ͢σʔλແ͍ͷͰ Voidʢʹ()ʣ return .success(()) }
Optional<Void> ʮBool ͩͱԿͷਅِ͔͕ᐆດɻVoid? ྃͱ͍͏ग़དྷࣄΛܕͰදݱʯ private var presented: Void? = nil
func presentIfNeeded() { guard presented == nil else { return } // طʹ࣮ߦࡁΈ presentOnboardingUI() presented = () // ࣮ߦࡁΈͷࠟΛه }
Reactive / Combine ʮ“Πϕϯτ͕ى͖ͨ”͚ͩΛ͑Δʯ final class ViewModel { let didTap
= PassthroughSubject<Void, Never>() // ͳ͠Πϕϯτ func onButtonTap() { didTap.send(()) // Voidܕͷ () ΛૹΔ } }
Neverͱͷରൺ func log() -> Void { } // ݺΜͩΒΔ func
crash() -> Never { fatalError() } // ݺΜͩΒΒͳ͍
ͳͥ () -> () ࣮Ͱ͋·Γݟ͔͚ͳ͍ͷ͔ʁ 1. ՄಡੑॏࢹͷจԽɿ() -> Void ͷํ͕ײత
2. ެࣜAPIɾυΩϡϝϯτͷӨڹɿAppleඪ४ϥΠϒϥϦҰ؏ͯ͠ Void 3. ʮSwiftyʯ͞ͷٻɿSwiftจԽʮಡΈ͢͞ɾ׳शʯΛ༏ઌ 1. () -> Void = Swifty 2. () -> () = ਖ਼͍͚͠ͲҰॠҾ͔͔ͬΔ
·ͱΊ 1. ܕυΩϡϝϯτҎ্ʹ༤ห 1. Void / () ͷ͍͚͕ APIઃܭͰҙਤΛ͑ΔखஈʹͳΔ 2.
Result<Void, Error> Optional<Void> ͰʮແʯܕʹͰ͖Δ 3. Never ͱͷରൺͰʮฦ͞ͳ͍ʯͱʮฦͤͳ͍ʯ͕໌֬ʹ۠ผͰ͖Δ 4. ࣋ͪؼΓ: ʮΓͳ͠ʯΛܰࢹͤͣɺܕͰҙਤΛਖ਼͑͘͠Α͏
ܕϓϩάϥϛϯάྑ͍