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
350
巨大な機能を VIPER + MicroViewController でいい感じに実装した話
yuichirokato
1
810
Mobile Programming Protocol Extension
yuichirokato
0
83
Mobile Programming Protocol
yuichirokato
0
87
Mobile Programming enum
yuichirokato
0
170
Mobile Programming Optional
yuichirokato
0
140
Mobile Programming Struct
yuichirokato
0
130
Mobile Programming Initializer Beta
yuichirokato
0
120
Mobile Programming Inheritance
yuichirokato
0
150
Other Decks in Technology
See All in Technology
Findy Freelance 利用シーン別AI活用例
ness
0
490
AIに目を奪われすぎて、周りの困っている人間が見えなくなっていませんか?
cap120
1
630
GMOペパボのデータ基盤とデータ活用の現在地 / Current State of GMO Pepabo's Data Infrastructure and Data Utilization
zaimy
3
220
Nx × AI によるモノレポ活用 〜コードジェネレーター編〜
puku0x
0
560
【CEDEC2025】『Shadowverse: Worlds Beyond』二度目のDCG開発でゲームをリデザインする~遊びやすさと競技性の両立~
cygames
PRO
1
370
マルチプロダクト×マルチテナントを支えるモジュラモノリスを中心としたアソビューのアーキテクチャ
disc99
1
530
[OCI Technical Deep Dive] OracleのAI戦略(2025年8月5日開催)
oracle4engineer
PRO
1
170
Google Agentspaceを実際に導入した効果と今後の展望
mixi_engineers
PRO
3
700
専門分化が進む分業下でもユーザーが本当に欲しかったものを追求するプロダクトマネジメント/Focus on real user needs despite deep specialization and division of labor
moriyuya
1
1.3k
Claude Codeから我々が学ぶべきこと
oikon48
10
2.8k
結局QUICで通信は速くなるの?
kota_yata
3
3.2k
いかにして命令の入れ替わりについて心配するのをやめ、メモリモデルを愛するようになったか(改)
nullpo_head
7
2.6k
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
The Cost Of JavaScript in 2023
addyosmani
51
8.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Building an army of robots
kneath
306
45k
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