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
53
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
Balancing Empowerment & Direction
lara
6
1.3k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
560
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
510
The Cost Of JavaScript in 2023
addyosmani
55
10k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
550
The World Runs on Bad Software
bkeepers
PRO
72
12k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
580
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
710
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Un-Boring Meetings
codingconduct
0
420
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
How to build a perfect <img>
jonoalderson
1
6k
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. ࣋ͪؼΓ: ʮΓͳ͠ʯΛܰࢹͤͣɺܕͰҙਤΛਖ਼͑͘͠Α͏
ܕϓϩάϥϛϯάྑ͍