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
enum as Option.
Search
r-plus
June 21, 2018
Technology
0
2.3k
enum as Option.
enum as Option.
potatotips #52
r-plus
June 21, 2018
Tweet
Share
More Decks by r-plus
See All by r-plus
Swizzling Swizzling Swizzling
r_plus
0
420
Image optimization for mobile on CDN
r_plus
0
690
Advanced guard of DeallocationChecker
r_plus
2
3.2k
東急ハンズの P2Pレジ間通信2018
r_plus
4
2.2k
Enterprise cert management.
r_plus
0
400
CircleCI 2.0 for macOS
r_plus
1
1.3k
carthage verify
r_plus
2
5.9k
業務アプリの切札 Programable KIOSK mode 大全
r_plus
0
4.3k
PropertyObserverとinoutでやらかした話
r_plus
1
1.3k
Other Decks in Technology
See All in Technology
問い合わせ自動化の技術的挑戦
recruitengineers
PRO
2
100
社内ワークショップで終わらせない 業務改善AIエージェント開発
lycorptech_jp
PRO
1
440
Vertex AI Agent Engine で学ぶ「記憶」の設計
tkikuchi
0
120
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
サンタコンペ2025完全攻略 ~お前らの焼きなましは遅すぎる~
terryu16
1
560
dbt meetup #19 『dbtを『なんとなく動かす』を卒業します』
tiltmax3
0
140
LINEヤフーにおけるAI駆動開発組織のプロデュース施策
lycorptech_jp
PRO
0
350
オンプレとGoogle Cloudを安全に繋ぐための、セキュア通信の勘所
waiwai2111
3
1.1k
どこで打鍵するのが良い? IaCの実行基盤選定について
nrinetcom
PRO
2
110
Master Dataグループ紹介資料
sansan33
PRO
1
4.4k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
2026-02-24 月末 Tech Lunch Online #10 Cloud Runのデプロイの課題から考えるアプリとインフラの境界線
masasuzu
0
110
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
How to make the Groovebox
asonas
2
2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Odyssey Design
rkendrick25
PRO
2
530
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
480
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
190
AI: The stuff that nobody shows you
jnunemaker
PRO
3
340
A Tale of Four Properties
chriscoyier
162
24k
Building an army of robots
kneath
306
46k
So, you think you're a good person
axbom
PRO
2
1.9k
Claude Code のすすめ
schroneko
67
220k
Transcript
FOVN BT0QUJPO 6/21 potatotips #52 taiki komaba(@r_plus)
UBJLJLPNBCB !S@QMVT
0QUJPO4FU
CJUຖʹΦϓγϣϯΛׂͯΔ ΦϓγϣϯͷͨΊͷͷͬΆ͍
public extension DispatchQueue { public struct Attributes : OptionSet {
public let rawValue: UInt64 public init(rawValue: UInt64) { self.rawValue = rawValue } public static let concurrent = Attributes(rawValue: 1<<1) @available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) public static let initiallyInactive = Attributes(rawValue: 1<<2) … 'PVOEBUJPOͰ Α͘ΘΕ͍ͯΔ https://github.com/apple/swift/blob/master/stdlib/public/SDK/Dispatch/Queue.swift
struct ShippingOptions: OptionSet { let rawValue: Int static let nextDay
= ShippingOptions(rawValue: 1 << 0) static let secondDay = ShippingOptions(rawValue: 1 << 1) static let priority = ShippingOptions(rawValue: 1 << 2) static let standard = ShippingOptions(rawValue: 1 << 3) } ࣮͢Δͱ͜͏ͳΔ
self.doSomething(arg, option: [.nextDay, .priority]) … func doSomething(_ arg: Any, option:
ShippingOptions) { … } ͏ଆ͜͏
func doSomething(_ arg: Any, option: ShippingOptions) { if option.contains(.nextDay) {
… } if option.contains(. secondDay) { … } } ͰɺͲͷΦϓγϣϯ͕ࢦఆ͞Ε͔ͨͰ ڍಈΛม͑Δʜ
None
ͳΜ͔Φϓγϣϯఆ͍͚ͨͩ͠ʹͯ͠ هड़͕໘͡Όͳ͍ʁ struct ShippingOptions: OptionSet { let rawValue: Int static
let nextDay = ShippingOptions(rawValue: 1 << 0) static let secondDay = ShippingOptions(rawValue: 1 << 1) static let priority = ShippingOptions(rawValue: 1 << 2) static let standard = ShippingOptions(rawValue: 1 << 3) }
struct ShippingOptions: OptionSet { let rawValue: Int static let nextDay
= ShippingOptions(rawValue: 1 << 0) static let secondDay = ShippingOptions(rawValue: 1 << 1) static let priority = ShippingOptions(rawValue: 1 << 2) static let standard = ShippingOptions(rawValue: 1 << 3) } ͳΜ͔Φϓγϣϯఆ͍͚ͨͩ͠ʹͯ͠ هड़͕໘͡Όͳ͍ʁ ͜ͷ͋ͨΓ͕ɻ
FOVNͰͬͯΈΑ͏
0QUJPOఆٛˠγϯϓϧFOVN enum ShippingOptions { case nextDay case secondDay case priority
case standard }
self.doSomething(arg, option: .nextDay) … func doSomething(_ arg: Any, option: ShippingOptions)
{ … } ͏ଆ͕͜͏
͜ͷ··ͩͱ ෳΦϓγϣϯࢦఆ͕ग़དྷͳ͍ͷͰʜ
ՄมҾ ʢ7BSJBEJD1BSBNFUFSTʣ
͜͏ͩͬͨͷΛ self.doSomething(arg, option: .nextDay) … func doSomething(_ arg: Any, option:
ShippingOptions) { … }
self.doSomething(arg, option: .nextDay, . priority) … Մมʹ͢Δ func doSomething(_ arg:
Any, option: ShippingOptions…) {…}
func doSomething(_ arg: Any, option: ShippingOptions…) { if option.contains(.nextDay) {
… } if option.contains(. secondDay) { … } } ࣮ଆʹ"SSBZ͕དྷΔͷͰมߋͳ͠
·ͱΊ ϝιουͷΦϓγϣϯΛ ؆୯ʹఆ͍͚ٛͨͩ͠Ͱ͋ΕΞϦͳͷͰ
͓ΘΓɻ