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

kotlin season 1 - Part 2 기본 문법 1

TaeHwan
October 02, 2016

kotlin season 1 - Part 2 기본 문법 1

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

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

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

TaeHwan

October 02, 2016
Tweet

More Decks by TaeHwan

Other Decks in Education

Transcript

  1. Part 2 Kotlin ӝࠄ ޙߨ 1 Taehwan 1 ରࣁ؀ উ٘۽੉٘

    ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  2. Kotlin ӝࠄ ఋੑ • Double 64 : 123.5 • Float

    32 : 123.5F/123.5f • Long 64 : 123L/123l • Int 32 : 123 • Sort 16 • Byte 8 • String 3 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  3. ߸ࣻ ࢶ঱ ߑߨ val/var ߸ࣻ ੉ܴ: ߸ࣻ ఋੑ 5 ରࣁ؀

    উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  4. ߸ࣻ ࢶ঱ ߑߨ val/var ߸ࣻ ੉ܴ: ߸ࣻ ఋੑ val a:

    Int var a: Int 6 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  5. val/var? • val : Read-only • var : Read/Write 7

    ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  6. Java৬ ࠺Ү - val/var? val a: Int = 10 a

    = 123 // ERROR 8 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  7. Java৬ ࠺Ү - val/var? val a: Int = 10 a

    = 123 // ERROR var a: Int = 1 a = 123 // SUCCESS 9 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  8. Java৬ ࠺Ү - final : val // Java final int

    a = 123; 10 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  9. Java৬ ࠺Ү - final : val // Java final int

    a = 123; // Kotlin val a: Int = 123 11 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  10. Java৬ ࠺Ү - final : val // Java final int

    a = 123; // Kotlin val a: Int = 123 val a = 123 // Type ࢤۚ оמ 12 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  11. Java৬ ࠺Ү - var // Java int a = 123;

    13 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  12. Java৬ ࠺Ү - var // Java int a = 123;

    var a: Int = 123 14 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  13. Java৬ ࠺Ү - var // Java int a = 123;

    var a: Int = 123 var a = 123 // Type ࢤۚ оמ 15 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  14. ਬ୶ೞӝ val a: Long = 123 val b: Float =

    123.0F 16 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  15. ਬ୶ೞӝ val a: Long = 123 var a = 123L

    // Type ࢤۚ оמೞݴ Longਵ۽ ਬ୶ оמ val b: Float = 123.0F var b = 123.0f // Type ࢤۚ оמೞݴ Floatਵ۽ ਬ୶ оמ 17 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  16. Class class ClassName { fun sumPrint(a: Int, b: Int) {

    print(a + b) } fun sum(a: Int, b: Int): Int { return a + b } } 20 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  17. ௏ౣܽ ೣࣻ fun sumPrint(a: Int, b: Int) { print(a +

    b) } fun sum(a: Int, b: Int): Int { return a + b } 22 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  18. ௏ౣܽ ೣࣻ fun ೣࣻݺ(): Unit { ೣࣻ ੿੄ } //

    Unitח ࢤۚ оמ fun ೣࣻݺ(߸ࣻݺ: ߸ࣻఋੑ) { ೣࣻ ੿੄ } 23 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  19. ௏ౣܽ ೣࣻ - return fun ೣࣻݺ(): return ఋੑ { return

    ч } fun ೣࣻݺ(߸ࣻݺ: ߸ࣻఋੑ): return ఋੑ { return ч } 24 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  20. ೣࣻ ୷ডೞӝ Single-Expression functions class ClassName { fun sum(a: Int,

    b: Int): Int { return a + b } } 25 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  21. ೣࣻ ୷ডೞӝ Single-Expression functions class ClassName { fun sum(a: Int,

    b: Int): Int { return a + b } fun sum(a: Int, b: Int): Int = a + b } 26 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  22. ೣࣻ ୷ডೞӝ Single-Expression functions class ClassName { fun sum(a: Int,

    b: Int): Int { return a + b } fun sum(a: Int, b: Int): Int = a + b fun sum(a: Int, b: Int) = a + b // Intܳ ਬ୶ оמ } 27 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  23. ૑৉ ೣࣻ fun getLength(obj: Any): Int { fun getSize(item: String)

    = item.length if (obj is String) { return getSize(obj) } return 0 } 28 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  24. Infix notation(઺ਤ ಴ӝߨ) fun Int.max(x: Int): Int = if (this

    > x) this else x 1.max(15) 29 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  25. Infix notation(઺ਤ ಴ӝߨ) infix fun Int.max(x: Int): Int = if

    (this > x) this else x 1 max 15 30 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016