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
Mobile Programming Closure
Search
yuichiro_takahashi
October 22, 2018
Technology
0
100
Mobile Programming Closure
Mobile Programmingの授業のスライドです
yuichiro_takahashi
October 22, 2018
Tweet
Share
More Decks by yuichiro_takahashi
See All by yuichiro_takahashi
App Clip - in a nutshell
yuichirokato
0
310
巨大な機能を VIPER + MicroViewController でいい感じに実装した話
yuichirokato
1
770
Mobile Programming Protocol Extension
yuichirokato
0
77
Mobile Programming Protocol
yuichirokato
0
79
Mobile Programming enum
yuichirokato
0
160
Mobile Programming Optional
yuichirokato
0
130
Mobile Programming Struct
yuichirokato
0
120
Mobile Programming Initializer Beta
yuichirokato
0
120
Mobile Programming Inheritance
yuichirokato
0
140
Other Decks in Technology
See All in Technology
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
120
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
210
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
520
C++26 エラー性動作
faithandbrave
2
680
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
180
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
180
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
510
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
440
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
180
Featured
See All Featured
Thoughts on Productivity
jonyablonski
67
4.4k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Bash Introduction
62gerente
608
210k
Designing Experiences People Love
moore
138
23k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
It's Worth the Effort
3n
183
28k
We Have a Design System, Now What?
morganepeng
51
7.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Rails Girls Zürich Keynote
gr2m
94
13k
Transcript
Ϋϩʔδϟ .PCJMF1SPHSBNNJOH0DU UI
ແ໊ؔ Ϋϩʔδϟ
ແ໊ؔ Ϋϩʔδϟ ͱʁ w ໊લͷ௨Γ໊લͷͳ͍ؔ w ໊લ͖ͭؔͱେ͖͘ҧ͏ͱ͜Ζ w มʹೖΕΒΕΔ w
ͱͯ͠ѻ͑Δͱ͍͏ͱ͜Ζ w ߏจएׯมΘΓ·͢ w ϥϜμࣜͳΜͯݺͼํ
ΫϩʔδϟΫοΩϯά { } w ೋͭͷΛड͚औͬͯ͠߹ΘͤΔؔΛߟ͑·͢ w ·ͣΫϩʔδϟͷ࢝·ΓͰ͋Δ\^Λهड़ ·ͣ͜Εʂ
ΫϩʔδϟΫοΩϯά { (number1: Int, number2: Int) -> Int in }
w ࣍ʹΫϩʔδϟ͕ड͚औΔҾΛઃఆ͍͖ͯ͠·͢ w ࠓճ͠ࢉͷؔͳͷͰҾೋͭʹͳΓ·͢ w ؔͱಉ͡Α͏ʹҾ໊લܕͱ͍͏ܗͰఆٛ͞Ε w ෳ͋Δ߹ΧϯϚͰ۠Γ·͢ Ҿ Ҿ Ҿಉ࢜ΧϯϚͰ۠Δ
ΫϩʔδϟΫοΩϯά w ࣍ʹΓΛܾΊ·͢ w ྫ͑ࠓճ͠ࢉͷؔͳͷͰ*OUܕΛҰͭฦ͠·͢ w Կฦ͢ͷ͕ͳ͍߹লུՄೳͰ͢ w ͪͳΈʹฦΓͱݴͬͨΓ͠·͕͢৭ʑΞϨͳͷͰࠓճΓͱݺͼ·͢ w
ΫϩʔδϟͰΓͷޙʹJOͱ͍͏Ωʔϫʔυ͕ඞཁʹͳΓ·͢ ͜ͷ෦͕Γ { (number1: Int, number2: Int) -> Int in } Εͣʹʂ
ΫϩʔδϟΫοΩϯά { (number1: Int, number2: Int) -> Int in let
result = number1 + number2 return result } w ࠷ޙʹΫϩʔδϟͷதΛهड़͍͖ͯ͠·͢ w Γ͕͋Δؔͷ߹ඞͣ࠷ޙʹ w SFUVSOΛ༻ͯ͠Λฦ͢ඞཁ͕͋Γ·͢ ΓΛฦ͢ ؔͰߦ͏ॲཧ
Ϋϩʔδϟͷݺͼग़͠ w ؔͱಉ༷ʹΫϩʔδϟݺͼग़͞ΕΔ·Ͱ࣮ߦ͞Εͳ͍ w ͦͷͨΊఆٛͨ͠ޙʹඞͣݺͼग़͢ඞཁ͕͋Δ w ΫϩʔδϟΛݺͼग़͢߹جຊతʹҰมʹೖΕΔඞཁ͕͋Δ // Ϋϩʔδϟͷఆٛ let
closure = { (number1: Int, number2: Int) -> Int in let result = number1 + number2 return result } // Ϋϩʔδϟͷݺͼग़͠ let added = closure(10, 10) print("result is: \(added)") // 20
ؔܕҾ ճ
ؔܕҾʁ w ઌ΄Ͳઆ໌ͨ͠ΫϩʔδϟΛҾʹͨ͠ͱ͖ͷ໊લ w Ϋϩʔδϟͱͯ͠ѻ͑ΔͨΊؔͷҾʹ͢͜ͱ ͕Ͱ͖Δ w ܁Γฦ͠ͷ࣌ʹग़͖ͯͨNBQΫϩʔδϟΛҾʹͱΔ ؔͰ͋Δ
ؔܕҾʁ // ΫϩʔδϟΛҾʹؚΉؔఆٛ func calculate(number1: Int, number2: Int, calc: ((Int,
Int) -> Int)) -> Int { return calc(number1, number2) } // ؔݺͼग़͠(ΫϩʔδϟҎ֎ͷҾΛຒΊΔ) calculate(number1: 10, number2: 10, calc:)
ؔܕҾʁ // ΫϩʔδϟΛҾʹؚΉؔఆٛ func calculate(number1: Int, number2: Int, calc: ((Int,
Int) -> Int)) -> Int { return calc(number1, number2) } // ؔݺͼग़͠(Ϋϩʔδϟͷ࢝·ΓͷΧοίΛॻ͍ͯɾɾɾ)͘ calculate(number1: 10, number2: 10, calc: { })
ؔܕҾʁ // ΫϩʔδϟΛҾʹؚΉؔఆٛ func calculate(number1: Int, number2: Int, calc: ((Int,
Int) -> Int)) -> Int { return calc(number1, number2) } // ؔݺͼग़͠(Ҿͷ໊લͱܕͱΓͷܕΛॻ͍ͯɾɾɾɾ) calculate(number1: 10, number2: 10, calc: { (num1: Int, num2: Int) -> Int })
ؔܕҾʁ // ΫϩʔδϟΛҾʹؚΉؔఆٛ func calculate(number1: Int, number2: Int, calc: ((Int,
Int) -> Int)) -> Int { return calc(number1, number2) } // ؔݺͼग़͠(in ΩʔϫʔυΛॻ͍ͯɾɾɾ) calculate(number1: 10, number2: 10, calc: { (num1: Int, num2: Int) -> Int in })
ؔܕҾʁ // ΫϩʔδϟΛҾʹؚΉؔఆٛ func calculate(number1: Int, number2: Int, calc: ((Int,
Int) -> Int)) -> Int { return calc(number1, number2) } // ؔݺͼग़͠(࠷ޙʹॲཧΛॻ͘ɾɾɾ) calculate(number1: 10, number2: 10, calc: { (num1: Int, num2: Int) -> Int in return num1 + num2 })
0I.Z (PPPPPPPPPPPPPPPPPPPPPPPPP
ྲྀੴʹΊΜͲ͍͘͞
Ϋϩʔδϟͷলུه๏
͖ͬ͞ͷྫΛ͏Ұ // ͬͪ͜লུͰ͖ͳ͍͕ɾɾɾ func calculate(number1: Int, number2: Int, calc: ((Int,
Int) -> Int)) -> Int { return calc(number1, number2) } // ͬͪ͜লུ͢Δͱɾɾɾ calculate(number1: 10, number2: 10, calc: { (num1: Int, num2: Int) -> Int return num1 + num2 }) ͜ͷ͍Ϋϩʔδϟ͕͋Δ͡ΌΖʁ
͖ͬ͞ͷྫΛ͏Ұ // ͬͪ͜লུͰ͖ͳ͍͕ɾɾɾ func calculate(number1: Int, number2: Int, calc: ((Int,
Int) -> Int)) -> Int { return calc(number1, number2) } // ͬͪ͜লུ͢Δͱɾɾɾ calculate(number1: 10, number2: 10) { (num1, num2) in return num1 + num2 } ͜ΕΛ͜͏ͯ͠ɾɾɾ
͖ͬ͞ͷྫΛ͏Ұ // ͬͪ͜লུͰ͖ͳ͍͕ɾɾɾ func calculate(number1: Int, number2: Int, calc: ((Int,
Int) -> Int)) -> Int { return calc(number1, number2) } // ͬͪ͜লུ͢Δͱɾɾɾ calculate(number1: 10, number2: 10ʣ{ $0 + $1 } ͜͏͡Όʂ
None
ॱΛͬͯઆ໌͠·͢
Ϋϩʔδϟͷޙஔه๏
Ϋϩʔδϟͷޙஔه๏ w ؔͷҾͷ࠷ޙ͕Ϋϩʔδϟͷ߹ͦͷΫϩʔδϟΛҾ Ϧετͷ֎ʹग़͢͜ͱ͕Ͱ͖·͢ w ͜ΕΛΫϩʔδϟͷޙஔه๏ 5SBJMMJOH$MPTVSF ͱݺͼ· ͢ calculate(number1:
10, number2: 10) { (num1: Int, num2: Int) -> Int in return num1 + num2 } calculate(number1: 10, number2: 10, calc: { (num1: Int, num2: Int) -> Int return num1 + num2 }) #FGPSF "GUFS
Ϋϩʔδϟͷܕͷলུ
Ϋϩʔδϟͷܕͷলུ w 4XJGUʹܕਪ͕͋ΔͨΊΫϩʔδϟͷҾͱΓͷ ܕΛলུͰ͖Δ߹͕͋Γ·͢ calculate(number1: 10, number2: 10) { (num1,
num2) in return num1 + num2 } calculate(number1: 10, number2: 10) { (num1: Int, num2: Int) -> Int in return num1 + num2 } #FGPSF "GUFS
Ϋϩʔδϟͷม໊ͷ লུ
Ϋϩʔδϟͷม໊ͷলུ w Ϋϩʔδϟͷॲཧ͕ߦͰࡁΉ߹มͷ໊લলུ͢Δ͜ͱ͕ Ͱ͖·͢ w ΘΓʹOͱ͍͏දهΛ͍·͢ w Ҿ͕ෳ͋Δ߹ࠨ͔Β ʜͱ͍͏ܗʹͳΓ·͢ w
·ͨɺSFUVSOলུՄೳͰ͢ calculate(number1: 10, number2: 10) { $0 + $1 } calculate(number1: 10, number2: 10) { (num1, num2) in return num1 + num2 } #FGPSF "GUFS