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
AWS re:Invent 2024 ふりかえり
kongmingstrap
0
110
製造の課題に立ち向かう Manufacturing Data Engine と Manufacturing Connect の ご紹介
kongmingstrap
0
650
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
610
JAWS-UG 福岡 #16 re:Invent 現地に行った人のお話 #jawsugfuk #jawsug
kongmingstrap
0
510
AppMod の開発のイマを知るために現地に潜入した私が見たものは・・・? #GoogleCloudNext
kongmingstrap
0
550
Kong Gateway から読みとく、 API統合・API連携サービスの最新情報 #devio2023
kongmingstrap
0
1.6k
Cloud Run に憧れて Google Cloud を推進している話 / CX事業本部で使われている技術
kongmingstrap
0
220
AWS / Google Cloud / Azure それぞれの推しサービス.pdf
kongmingstrap
0
1.3k
CPUブーストの話
kongmingstrap
0
60
Other Decks in Technology
See All in Technology
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
140
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
320
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
IVRyエンジニア忘年LT大会2024 クリティカルユーザージャーニーの整理
abnoumaru
0
160
ジャンプTOONにおける サイトマップの自動生成手法
assa1605
0
110
アップデート紹介:AWS Data Transfer Terminal
stknohg
PRO
0
150
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
180
イノベーショントークから見るクラウド運用の未来を振り返ってみた
nyankotaro
0
470
職能を超えたモブプログラミングが品質に与えた良い影響
tonionagauzzi
2
340
Amazon Bedrock Knowledge BasesがGraphRAGに対応!! ・・・それってつまりどういうコト!? をチョット深堀ってみる
tokushun
0
200
テーブルが200以上あるSaaSでRSCとGraphQLを併用する理由
msickpaler
2
1.2k
うまくいく! を実現するための質問力 / It works! The Power of Questions to Make It Happen
bitkey
PRO
1
320
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
65
11k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Scaling GitHub
holman
458
140k
GraphQLとの向き合い方2022年版
quramy
44
13k
Agile that works and the tools we love
rasmusluckow
328
21k
Being A Developer After 40
akosma
87
590k
The Language of Interfaces
destraynor
154
24k
Rails Girls Zürich Keynote
gr2m
94
13k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Documentation Writing (for coders)
carmenintech
66
4.5k
YesSQL, Process and Tooling at Scale
rocio
169
14k
4 Signs Your Business is Dying
shpigford
181
21k
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