Slide 1

Slide 1 text

Ϋϩʔδϟ .PCJMF1SPHSBNNJOH0DU UI

Slide 2

Slide 2 text

ແ໊ؔ਺ Ϋϩʔδϟ

Slide 3

Slide 3 text

ແ໊ؔ਺ Ϋϩʔδϟ ͱ͸ʁ w ໊લͷ௨Γ໊લͷͳ͍ؔ਺ w ໊લ͖ͭؔ਺ͱେ͖͘ҧ͏ͱ͜Ζ͸ w ม਺ʹೖΕΒΕΔ w ஋ͱͯ͠ѻ͑Δͱ͍͏ͱ͜Ζ w ߏจ΋एׯมΘΓ·͢ w ϥϜμࣜͳΜͯݺͼํ΋

Slide 4

Slide 4 text

Ϋϩʔδϟ෼ΫοΩϯά { } w ೋͭͷ਺஋Λड͚औͬͯ଍͠߹ΘͤΔؔ਺Λߟ͑·͢ w ·ͣ͸Ϋϩʔδϟͷ࢝·ΓͰ͋Δ\^Λهड़ ·ͣ͸͜Εʂ

Slide 5

Slide 5 text

Ϋϩʔδϟ෼ΫοΩϯά { (number1: Int, number2: Int) -> Int in } w ࣍ʹΫϩʔδϟ͕ड͚औΔ஋Ҿ਺Λઃఆ͍͖ͯ͠·͢ w ࠓճ͸଍͠ࢉͷؔ਺ͳͷͰҾ਺͸ೋͭʹͳΓ·͢ w ؔ਺ͱಉ͡Α͏ʹҾ਺͸໊લܕͱ͍͏ܗͰఆٛ͞Ε w ෳ਺͋Δ৔߹͸ΧϯϚͰ۠੾Γ·͢ Ҿ਺ Ҿ਺ Ҿ਺ಉ࢜͸ΧϯϚͰ۠੾Δ

Slide 6

Slide 6 text

Ϋϩʔδϟ෼ΫοΩϯά w ࣍ʹ໭Γ஋ΛܾΊ·͢ w ྫ͑͹ࠓճ͸଍͠ࢉͷؔ਺ͳͷͰ*OUܕΛҰͭฦ͠·͢ w Կ΋ฦ͢΋ͷ͕ͳ͍৔߹͸লུՄೳͰ͢ w ͪͳΈʹฦΓ஋ͱ΋ݴͬͨΓ͠·͕͢৭ʑΞϨͳͷͰࠓճ͸໭Γ஋ͱݺͼ·͢ w ΫϩʔδϟͰ͸໭Γ஋ͷޙʹJOͱ͍͏Ωʔϫʔυ͕ඞཁʹͳΓ·͢ ͜ͷ෦෼͕໭Γ஋ { (number1: Int, number2: Int) -> Int in } ๨Εͣʹʂ

Slide 7

Slide 7 text

Ϋϩʔδϟ෼ΫοΩϯά { (number1: Int, number2: Int) -> Int in let result = number1 + number2 return result } w ࠷ޙʹΫϩʔδϟͷத਎Λهड़͍͖ͯ͠·͢ w ໭Γ஋͕͋Δؔ਺ͷ৔߹͸ඞͣ࠷ޙʹ w SFUVSOΛ࢖༻ͯ͠஋Λฦ͢ඞཁ͕͋Γ·͢ ໭Γ஋Λฦ͢ ؔ਺Ͱߦ͏ॲཧ

Slide 8

Slide 8 text

Ϋϩʔδϟͷݺͼग़͠ 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

Slide 9

Slide 9 text

ؔ਺ܕҾ਺ ճ໨

Slide 10

Slide 10 text

ؔ਺ܕҾ਺ʁ w ઌ΄Ͳઆ໌ͨ͠ΫϩʔδϟΛҾ਺ʹͨ͠ͱ͖ͷ໊લ  w Ϋϩʔδϟ͸஋ͱͯ͠ѻ͑ΔͨΊؔ਺ͷҾ਺ʹ΋౉͢͜ͱ ͕Ͱ͖Δ w ܁Γฦ͠ͷ࣌ʹग़͖ͯͨNBQ΋ΫϩʔδϟΛҾ਺ʹͱΔ ؔ਺Ͱ͋Δ

Slide 11

Slide 11 text

ؔ਺ܕҾ਺ʁ // ΫϩʔδϟΛҾ਺ʹؚΉؔ਺ఆٛ func calculate(number1: Int, number2: Int, calc: ((Int, Int) -> Int)) -> Int { return calc(number1, number2) } // ؔ਺ݺͼग़͠(ΫϩʔδϟҎ֎ͷҾ਺ΛຒΊΔ) calculate(number1: 10, number2: 10, calc:)

Slide 12

Slide 12 text

ؔ਺ܕҾ਺ʁ // ΫϩʔδϟΛҾ਺ʹؚΉؔ਺ఆٛ func calculate(number1: Int, number2: Int, calc: ((Int, Int) -> Int)) -> Int { return calc(number1, number2) } // ؔ਺ݺͼग़͠(Ϋϩʔδϟͷ࢝·ΓͷΧοίΛॻ͍ͯɾɾɾ)͘ calculate(number1: 10, number2: 10, calc: { })

Slide 13

Slide 13 text

ؔ਺ܕҾ਺ʁ // ΫϩʔδϟΛҾ਺ʹؚΉؔ਺ఆٛ 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 })

Slide 14

Slide 14 text

ؔ਺ܕҾ਺ʁ // ΫϩʔδϟΛҾ਺ʹؚΉؔ਺ఆٛ 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 })

Slide 15

Slide 15 text

ؔ਺ܕҾ਺ʁ // ΫϩʔδϟΛҾ਺ʹؚΉؔ਺ఆٛ 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 })

Slide 16

Slide 16 text

0I.Z (PPPPPPPPPPPPPPPPPPPPPPPPP

Slide 17

Slide 17 text

ྲྀੴʹΊΜͲ͍͘͞

Slide 18

Slide 18 text

Ϋϩʔδϟͷলུه๏

Slide 19

Slide 19 text

͖ͬ͞ͷྫΛ΋͏Ұ౓ // ͬͪ͜͸লུͰ͖ͳ͍͕ɾɾɾ 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 }) ͜ͷ௕͍Ϋϩʔδϟ͕͋Δ͡ΌΖʁ

Slide 20

Slide 20 text

͖ͬ͞ͷྫΛ΋͏Ұ౓ // ͬͪ͜͸লུͰ͖ͳ͍͕ɾɾɾ 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 } ͜ΕΛ͜͏ͯ͠ɾɾɾ

Slide 21

Slide 21 text

͖ͬ͞ͷྫΛ΋͏Ұ౓ // ͬͪ͜͸লུͰ͖ͳ͍͕ɾɾɾ func calculate(number1: Int, number2: Int, calc: ((Int, Int) -> Int)) -> Int { return calc(number1, number2) } // ͬͪ͜͸লུ͢Δͱɾɾɾ calculate(number1: 10, number2: 10ʣ{ $0 + $1 } ͜͏͡Όʂ

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

ॱΛ௥ͬͯઆ໌͠·͢

Slide 24

Slide 24 text

Ϋϩʔδϟͷޙஔه๏

Slide 25

Slide 25 text

Ϋϩʔδϟͷޙஔه๏ 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

Slide 26

Slide 26 text

Ϋϩʔδϟͷܕͷলུ

Slide 27

Slide 27 text

Ϋϩʔδϟͷܕͷলུ 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

Slide 28

Slide 28 text

Ϋϩʔδϟͷม਺໊ͷ লུ

Slide 29

Slide 29 text

Ϋϩʔδϟͷม਺໊ͷলུ 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