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
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
0
110
MUITにおける開発プロセスモダナイズの取り組みと開発生産性可視化の取り組みについて / Modernize the Development Process and Visualize Development Productivity at MUIT
muit
1
16k
Delta airlines Customer®️ USA Contact Numbers: Complete 2025 Support Guide
deltahelp
0
690
Getting to Know Your Legacy (System) with AI-Driven Software Archeology (WeAreDevelopers World Congress 2025)
feststelltaste
1
130
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
2
7.7k
OPENLOGI Company Profile for engineer
hr01
1
34k
生成AI時代の開発組織・技術・プロセス 〜 ログラスの挑戦と考察 〜
itohiro73
1
460
SEQUENCE object comparison - db tech showcase 2025 LT2
nori_shinoda
0
140
united airlines ™®️ USA Contact Numbers: Complete 2025 Support Guide
flyunitedhelp
1
300
関数型プログラミングで 「脳がバグる」を乗り越える
manabeai
1
190
無意味な開発生産性の議論から抜け出すための予兆検知とお金とAI
i35_267
4
13k
Zephyr RTOSを使った開発コンペに参加した件
iotengineer22
1
220
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
Thoughts on Productivity
jonyablonski
69
4.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Making the Leap to Tech Lead
cromwellryan
134
9.4k
Unsuck your backbone
ammeep
671
58k
Speed Design
sergeychernyshev
32
1k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
How to Ace a Technical Interview
jacobian
278
23k
Balancing Empowerment & Direction
lara
1
430
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