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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
r-plus
June 21, 2018
Technology
2.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
enum as Option.
enum as Option.
potatotips #52
r-plus
June 21, 2018
More Decks by r-plus
See All by r-plus
Swizzling Swizzling Swizzling
r_plus
0
440
Image optimization for mobile on CDN
r_plus
0
700
Advanced guard of DeallocationChecker
r_plus
2
3.3k
東急ハンズの P2Pレジ間通信2018
r_plus
4
2.2k
Enterprise cert management.
r_plus
0
410
CircleCI 2.0 for macOS
r_plus
1
1.3k
carthage verify
r_plus
2
6k
業務アプリの切札 Programable KIOSK mode 大全
r_plus
0
4.3k
PropertyObserverとinoutでやらかした話
r_plus
1
1.3k
Other Decks in Technology
See All in Technology
Chainlitで作るお手軽チャットUI
ynt0485
0
270
自宅LLMの話
jacopen
1
610
Kiroで書いた 設計書 が AI レビューの 採点基準 になる
ezaki
0
130
AIのReact習熟度を測る
uhyo
2
640
AIはどのように 組織のアジリティを変えるのか?
junki
4
1k
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
1
130
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
220
Kubernetesにおける学習基盤とLLMOpsの概要
ry
1
320
ぼっちではじめた登壇が「51名」「241件」の発信に化けた
subroh0508
0
160
When Platform Engineering Meets GenAI
sucitw
0
120
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
160
AIソロプレナー時代に2ヶ月で20人増員した事業創造会社の開発組織の話
miyatakoji
0
690
Featured
See All Featured
Marketing to machines
jonoalderson
1
5.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
320
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Claude Code のすすめ
schroneko
67
230k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
630
How GitHub (no longer) Works
holman
316
150k
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͕དྷΔͷͰมߋͳ͠
·ͱΊ ϝιουͷΦϓγϣϯΛ ؆୯ʹఆ͍͚ٛͨͩ͠Ͱ͋ΕΞϦͳͷͰ
͓ΘΓɻ