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
51
WebViewの現在地 - SwiftUI時代のWebKit - / The Current State Of WebView
marcy731
0
340
めざせ!WKWebViewマスター! / WKWebView Master
marcy731
4
3.4k
GitHub Copilotのススメ
marcy731
1
1.5k
Introduction to Memory Management in Swift - Swiftのメモリ管理を知る -
marcy731
0
41
ステートマシンを活用した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
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Tell your own story through comics
letsgokoyo
1
1.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
A Soul's Torment
seathinner
7
3.6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.9k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Building AI with AI
inesmontani
PRO
1
1.2k
WCS-LA-2024
lcolladotor
0
830
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
820
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. ࣋ͪؼΓ: ʮΓͳ͠ʯΛܰࢹͤͣɺܕͰҙਤΛਖ਼͑͘͠Α͏
ܕϓϩάϥϛϯάྑ͍