Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Voidと() - 意図を伝える“ユニット型”の世界- / Void vs () -The W...
Search
marcy731
September 30, 2025
23
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
54
WebViewの現在地 - SwiftUI時代のWebKit - / The Current State Of WebView
marcy731
0
340
めざせ!WKWebViewマスター! / WKWebView Master
marcy731
4
3.5k
GitHub Copilotのススメ
marcy731
1
1.5k
Introduction to Memory Management in Swift - Swiftのメモリ管理を知る -
marcy731
0
45
ステートマシンを活用したWebView-ネイティブ間連携へのアプローチ / An Approach to WebView-Native Communication Using State Machines
marcy731
1
1.7k
WebViewをNativeのように使いたい / Using-WebView-like-Native-App
marcy731
2
680
「アプリをつくる仕組み」の構築 / build-system-for-STORES-Branded-Apps
marcy731
0
890
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Typedesign – Prime Four
hannesfritz
42
3.2k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
700
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
440
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
350
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
How to Talk to Developers About Accessibility
jct
2
560
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Designing Experiences People Love
moore
143
24k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
260
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. ࣋ͪؼΓ: ʮΓͳ͠ʯΛܰࢹͤͣɺܕͰҙਤΛਖ਼͑͘͠Α͏
ܕϓϩάϥϛϯάྑ͍