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

kotlin season 1 - Part 5 Null Safety

TaeHwan
October 06, 2016

kotlin season 1 - Part 5 Null Safety

2016년 유데미 Kotlin 강의를 공개합니다.

영상 : https://www.youtube.com/watch?v=XPY02DNeD5g

2회 분은 유데미에서 확인 가능합니다.
http://bit.ly/2UpaJUR

TaeHwan

October 06, 2016
Tweet

More Decks by TaeHwan

Other Decks in Education

Transcript

  1. Part 5 Kotlin Null Safety Taehwan 1 ରࣁ؀ উ٘۽੉٘ ѐߊ

    ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  2. द੘ೞӝ ੹ী? • ࢠ೒ ௏٘ : 02-null-safety 2 ରࣁ؀ উ٘۽੉٘

    ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  3. য়ט਷ • Java/Kotlin੄ null ಴അ ߑߨ • Kotlin੄ null ޙߨ

    য়ܨ • Kotlinীࢲ NULL ୊ܻ ઱੄ࢎ೦ • ੌ߈੸ੋ NULL ୓௼ೞӝ • Kotlin੄ Safe Calls 3 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  4. Null ୊ܻ ݫࣗ٘ - Java public void set(@NotNull String a,

    @Nullable String b) { // Do noting } 5 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  5. Null ୊ܻ ݫࣗ٘ - Kotlin fun set(a: String, b: String?)

    { // Do noting } 6 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  6. Java to Kotlin - NotNull @NotNull String a -> a:

    String 7 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  7. Java to Kotlin - Nullable @Nullable String b -> b:

    String? 8 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  8. Kotlin ޙߨ য়ܨ var temp: String = "abc" temp =

    null // ޙߨ য়ܨ ߊࢤ 10 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  9. Kotlinীࢲ NULL ୊ܻ var temp: String? = "abc" temp =

    null 11 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  10. Kotlinীࢲ NULL ୊ܻ ઱੄ࢎ೦ • NULLਸ ೞӝ ਤೠ ?ীח Typeਸ

    ॄঠ ೠ׮. var temp = null temp = "ABC" // Type য়ܨ ߊࢤ 13 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  11. Kotlinীࢲ NULL ୊ܻ ઱੄ࢎ೦ • NULLਸ ೞӝ ਤೠ ?ীח Typeਸ

    ॄঠ ೠ׮. var temp: String? = null temp = "ABC" 14 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  12. Javaীࢲ੄ NULL ୓௼ String temp = null; int size =

    -1; if (temp != null) { size = temp.length(); } 16 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  13. null ୓௼ - java String temp = null; int size

    = 0; if (!TextUtils.isEmpty(temp)) { size = temp.length(); } 17 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  14. null ୓௼ - kotlin var temp: String? = null var

    size = -1 if (temp != null) { size = temp.length } 18 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  15. null ୓௼ рױ ಴അध - java String temp = null;

    int size = temp != null ? temp.length() : 0; 19 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  16. null ୓௼ рױ ಴അध - kotlin var temp: String? =

    null val size = if (temp != null) temp.length else 0 20 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  17. Kotlin Safe Calls // nullਸ ನೣ ೡ ࣻ ੓ח temp

    var ߸ࣻ੉ݴ, null۽ ୡӝച ೤פ׮. var temp: String? = null 22 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  18. Kotlin Safe Calls // nullਸ ನೣ ೡ ࣻ ੓ח temp

    var ߸ࣻ੉ݴ, null۽ ୡӝച ೤פ׮. var temp: String? = null // ޛ਺಴(?.)ܳ ׮द ೠߣ ನೣ೤פ׮. val size = temp?.length 23 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  19. Safe Calls ೣࣻীࢲ ࢎਊ ߑߨ - Java int getSize(String temp)

    { return temp != null ? temp.length : null } 24 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  20. Safe Calls ೣࣻীࢲ ࢎਊ ߑߨ - Kotlin fun getSize(temp: String?):

    Int? { return temp?.length } 25 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  21. Safe Calls ೣࣻীࢲ ࢎਊ ߑߨ - Kotlin fun getSize(temp: String?):

    Int? { // tempо NULL੉ݶ null੉ return // tempо NULL੉ ইפݶ lengthо return return temp?.length } 26 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  22. Safe Calls੄ ੢੼਷?? - Java // ׮਺җ э੉ ୡӝച غ঻ਸ

    ҃਋ // abc = ABC() // bbb = BBB() // ddd = null if (abc != null && bbb != null && ddd != null) { return abc.bbb.ddd.name; } return null; 27 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  23. Safe Calls੄ ੢੼਷?? - kotlin // ׮਺җ э੉ ୡӝച غ঻ਸ

    ҃਋ // abc = ABC() // bbb = BBB() // ddd = null return abc?.bbb?.ddd?.name 28 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  24. ׮਺਷ • উ੹ೠ NULL ୊ܻ 2ࠗ 30 ରࣁ؀ উ٘۽੉٘ ѐߊ

    ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016