Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift3.0が出る前に 基礎の見直し:guard

Swift3.0が出る前に 基礎の見直し:guard

Early Exit

7d709dd44f86dc8f2b7ddb4c48145dfc?s=128

jollyjoester

July 02, 2016
Tweet

More Decks by jollyjoester

Other Decks in Education

Transcript

  1. Swift3.0͕ग़Δલʹ جૅͷݟ௚͠ɿguard 2016/07/02 SwiftϏΪφʔζษڧձ ୈ15ճ @ίϫʔΩϯάεϖʔεכ৔ொ Co-Edo

  2. • ࣣౡҒ೭ʢͳͳ͠·ͻͰΏ͖ʣ • Repro (ΞϓϦ޲͚෼ੳˍϚʔέπʔϧ) • ΞϓϦ։ൃೖ໳ऀʹ༏͍͠Ωϟϥ
 ʢTeratail / LIGϒϩά

    / Schooʣ • ੈքҰຊ Coming Soon
  3. Swift https://speakerdeck.com/jollyjoester/ swiftfalsepointokaitumami

  4. 1೥લ->ࠓճ • let / var : ࠶୅ೖͰ͖Δ͔൱Λ໌֬ʹ෼཭ • struct /

    class : ঢ়ଶͷ༗ແΛ໌֬ʹ෼཭ • Optional : nil͔஋͋Γ͔Λ໌֬ʹ෼཭ • ɾɾɾ • ʲࠓճʳҟৗܥͱਖ਼ৗܥΛ໌֬ʹ෼཭
  5. guard Early Exit A guard statement, like an if statement,

    executes statements depending on the Boolean value of an expression. You use a guard statement to require that a condition must be true in order for the code after the guard statement to be executed. ཁ͸ifΈ͍ͨͳ΍ͭͬͯ͜ͱͰɻ Excerpt From: Apple Inc. “The Swift Programming Language (Swift 2.1).” iBooks. https://itun.es/jp/jEUH0.l
  6. ͦͷ̍ ObjCͰεϚϯ

  7. ͦͷ̎ ObjCͰεϚϯ

  8. Early Exit ObjCͰεϚϯ

  9. Early Exit ωετ΋ݮΔ

  10. Early Exit ͬͯReadable Codeઌੜ΋ݴͬͯͨ

  11. SwiftͰ΋ͦͷ̍

  12. SwiftͰ΋ͦͷ̎ SwiftͰ΋

  13. guard SwiftͰ΋

  14. ͜͏͍͏ͷ΋

  15. Swift͖ͬͪΓͯͯ͠ॿ͔ΔΘʙ

  16. એ఻ http://love-swift.connpass.com/ ࣍ճ͸7/31