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

kotlin season 1 - Part 3 기본 문법 2

TaeHwan
October 03, 2016

kotlin season 1 - Part 3 기본 문법 2

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

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

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

TaeHwan

October 03, 2016
Tweet

More Decks by TaeHwan

Other Decks in Education

Transcript

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

    ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  2. NULL ੸ਊೞӝ var a: Int = 123 a = null

    3 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  3. NULL ੸ਊೞӝ var a: Int = 123 a = null

    // ޙߨ࢚ য়ܨ ߊࢤ 4 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  4. NULL ੸ਊೞӝ var a: Int? = 123 6 ରࣁ؀ উ٘۽੉٘

    ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  5. NULL ੸ਊೞӝ var a: Int? = 123 a = null

    // ࢿҕ 7 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  6. String templates - Java String name = "kotlin"; int age

    = 10; String query = "Name " + name + " Age " + age; print : Name kotlin Age 10 9 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  7. String templates - Kotlin val name = "kotlin" val age

    = 10 val query = "Name $name Age $age" print : Name kotlin Age 10 10 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  8. String templates - Kotlin val name = "kotlin" val query

    = "Name $name Name Size : ${name.length}" print : Name kotlin Name Size : 6 11 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  9. Java Object private int getLength(Object obj) { if (obj instanceof

    String) { return ((String) obj).length(); } return 0; } 13 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  10. Any // kotlin fun getLength(obj: Any): Int { if (obj

    is String) { return obj.length } return 0 } 14 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  11. Any ਬਊೞѱ ࢎਊೞӝ fun cases(obj: Any) { when (obj) {

    1 -> println("One") "Hello" -> println("Greeting") is Long -> println("Long") !is String -> println("Not a string") else -> println("Unknown") } } 15 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  12. loop - java ArrayList<String> arrayList = new ArrayList<>(); for (String

    s : arrayList) { Log.d("TAG", "string : " + s); } 17 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  13. loop - kotlin val arrayList = ArrayList<String>() for (s in

    arrayList) { Log.d("TAG", "string : " + s) } 18 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  14. loop - ranges - java for (int i = 1;

    i <= 5; i++) { Log.i("TAG", "index : " + i); } 19 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  15. loop - ranges - kotlin for (x in 1..5) {

    println(x) } 20 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  16. Lambdas button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) {

    view.setAlpha(0.5f); } }); 21 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  17. Lambdas button.setOnClickListener { view -> view.alpha = 0.5f } 22

    ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  18. Lambdas button.setOnClickListener { it.alpha = 0.5f } 23 ରࣁ؀ উ٘۽੉٘

    ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  19. stream for (Integer integer : list) { if (integer >

    5) { integer *= 2; Log.e("TAG", "Index " + integer); } } 24 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016
  20. stream list.filter { it > 5 }.map { Log.d("TAG", "index

    " + (it * 2)) } 25 ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016