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
Swiftをキめると 気持ちいい!
Search
Takaaki Tanaka
July 26, 2016
Technology
0
1.1k
Swiftをキめると 気持ちいい!
AKIBAswift #04での資料です
Takaaki Tanaka
July 26, 2016
Tweet
Share
More Decks by Takaaki Tanaka
See All by Takaaki Tanaka
製造の課題に立ち向かう Manufacturing Data Engine と Manufacturing Connect の ご紹介
kongmingstrap
0
620
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
590
JAWS-UG 福岡 #16 re:Invent 現地に行った人のお話 #jawsugfuk #jawsug
kongmingstrap
0
490
AppMod の開発のイマを知るために現地に潜入した私が見たものは・・・? #GoogleCloudNext
kongmingstrap
0
540
Kong Gateway から読みとく、 API統合・API連携サービスの最新情報 #devio2023
kongmingstrap
0
1.5k
Cloud Run に憧れて Google Cloud を推進している話 / CX事業本部で使われている技術
kongmingstrap
0
210
AWS / Google Cloud / Azure それぞれの推しサービス.pdf
kongmingstrap
0
1.3k
CPUブーストの話
kongmingstrap
0
52
私のAWS愛を聞け! ~ここが好きだよStep Functions~ #devio2022
kongmingstrap
0
1.1k
Other Decks in Technology
See All in Technology
20241108_CS_LLMMT
shigashiyama
0
260
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
120
フルカイテン株式会社 採用資料
fullkaiten
0
40k
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
1
130
今、始める、第一歩。 / Your first step
yahonda
2
730
3次元点群データ「VIRTUAL SHIZUOKA』のオープンデータ化による恩恵と協働の未来/FOSS4G Japan 2024
kazz24s
0
140
エンジニア候補者向け資料2024.11.07.pdf
macloud
0
4.6k
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
0
1.8k
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
310
元旅行会社の情シス部員が教えるおすすめなre:Inventへの行き方 / What is the most efficient way to re:Invent
naospon
2
310
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
1
920
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
520
39k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Into the Great Unknown - MozCon
thekraken
32
1.5k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Gamification - CAS2011
davidbonilla
80
5k
Teambox: Starting and Learning
jrom
133
8.8k
Ruby is Unlike a Banana
tanoku
96
11k
RailsConf 2023
tenderlove
29
900
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Transcript
4XJGUΛΩΊΔͱ ؾ͍͍࣋ͪʂ AKIBA.swift #04
About Me • ాத ໌ (Takaaki Tanaka) • Ϋϥεϝιουגࣜձࣾ •
@kongmingtrap • iOS Developer (Swift / Objective-C) • GyazSquare / GitHub
օ༷
4XJGUॻ͍͍ͯ·͔͢ʁ
0CKFDUJWF$͔Βೖ͖ͬͯͨํʑ
πϥ͘ͳ͍Ͱ͔͢ʁ
πϥ͔ͬͨͰ͢ɻ
ͦΕ͔Βɻɻɻ৭ʑ͋Γɻɻɻ
ศརͳؔΛͬͯ ؆ܿʹॻ͘Α͏ʹ͢Δ͜ͱͰ ॻ͘ͷָ͕͘͠ͳ͖ͬͯ·ͨ͠ɻ
ศརͳؔ w GPS&BDI w NBQ w SFEVDF w pMUFS w
qBUNBQ
ศརͳؔ w GPS&BDI w NBQ w SFEVDF w pMUFS w
qBUNBQ
NBQqBUNBQ w 0QUJPOBM w 4FRVFODF5ZQF w $PMMFDUJPO w 'MBU.BQ ద༻͞Ε͍ͯΔऀͨͪ
NBQqBUNBQ public func map<U>( _ transform: @noescape (Wrapped) throws ->
U ) rethrows -> U? { switch self { case .some(let y): return .some(try transform(y)) case .none: return .none } }
ࡉ͔͍આ໌ল͍ͯޙʹͯͬͯ͠ΈΑ͏
NBQqBU.BQͰ ಈ࡞ΛൺͯΈΔ
&YBNQMF enum PokemonType: String { case Grass = "Grass" case
Water = "Water" case Fire = "Fire" case Electric = "Electric" } ͋Δ࣌͜Μͳ&OVN͕͓Γ·ͨ͠ɻ
4FRVFODF let types = ["Grass", "Water", "Fire", "Electric"] let pokemonTypes
= types.map { PokemonType(rawValue: $0) } [Optional PokemonType.Grass Optional PokemonType.Water Optional PokemonType.Fire Optional PokemonType.Electric ] ݁Ռ͕0QUJPOBMʹͳΔ
4FRVFODF let types = ["Grass", "Water", "Fire", "Electric"] let pokemonTypes
= types.flatMap { PokemonType(rawValue: $0) } [PokemonType.Grass PokemonType.Water PokemonType.Fire PokemonType.Electric] ݁Ռ͕VOXSBQ͞ΕΔ
4FRVFODF let types = ["Grass", "Water", "Fire", "Ice"] let pokemonTypes
= types.map { PokemonType(rawValue: $0) } [Optional PokemonType.Grass Optional PokemonType.Water Optional PokemonType.Fire nil] ۪ʹ݁ՌΛฦ͢
4FRVFODF let types = ["Grass", "Water", "Fire", "Ice"] let pokemonTypes
= types.flatMap { PokemonType(rawValue: $0) } [PokemonType.Grass PokemonType.Water PokemonType.Fire] ݁Ռ͕VOXSBQ͞ΕɺOJM͕ଧͪফ͞ΕΔ
$PMMFDUJPO let types1 = ["Electric", "Electric", "Fire"] let types2 =
["Water", "Ice"] let types3 = ["Fire", "Grass", "Rock", "Grass"] let types = [types1, types2, types3].map { $0 } [["Electric", "Electric", "Fire"], ["Water", "Ice"], ["Fire", "Grass", "Rock", "Grass"]]
$PMMFDUJPO let types1 = ["Electric", "Electric", "Fire"] let types2 =
["Water", "Ice"] let types3 = ["Fire", "Grass", "Rock", "Grass"] let types = [types1, types2, types3].flatMap { $0 } ["Electric", "Electric", "Fire", "Water", "Ice", "Fire", "Grass", "Rock", "Grass"] ݁Ռ͕qBUͳ"SSBZʹͳΔ
$PMMFDUJPO let types1 = ["Electric", "Electric", "Fire"] let types2 =
["Water", "Ice"] let types3 = ["Fire", "Grass", "Rock", "Grass"] let types = [types1, types2, types3].flatMap { $0 }.flatMap { PokemonType(rawValue: $0) } [PokemonType.Electric PokemonType.Electric PokemonType.Fire PokemonType.Water PokemonType.Fire PokemonType.Grass PokemonType.Grass] OJM͕ଧͪফ͞ΕΔͨΊɺཉ͍͠σʔλ͚ͩΔ
0QUJPOBM let value: String? = "Fire" let value1 = value.map
{ PokemonType(rawValue: $0) } Optional Optional PokemonType.Fire ݁Ռ͕ೋॏͷ0QUJPOBMʹͳΔ
0QUJPOBM let value: String? = "Fire" let value1 = value.flatMap
{ PokemonType(rawValue: $0) } Optional PokemonType.Fire ݁Ռͷ0QUJPOBM͕ଧͪফ͞ΕΔʢVOXSBQ͞ΕΔʣ
0QUJPOBM let type = PokemonType(rawValue: "Water") let changedType = pokemon.map
{ type -> PokemonType in switch type { case .Water: return PokemonType.Electric default: return type } } Optional PokemonType.Electric VOXSBQͯ͠ΛऔΓѻ͏
0QUJPOBM let value1: Int? = 10 let value2: Int? =
20 let value = value1.flatMap { v1 in value2.map { v2 in v1 + v2 } } Optional 30 0QUJPOBMಉ࢜ͷͷܭࢉ
·ͱΊ w ؆ܿʹॻ͜͏ w 0QUJPOBMͱྑ͖͘߹͓͏ w 1MBZHSPVOEΛ༗ޮ׆༻͠Α͏
5IBOL:PV