$30 off During Our Annual Pro Sale. View Details »

Kotlin in Google IO 2017 CA.apk

Kotlin in Google IO 2017 CA.apk

# Event
https://cyberagent.connpass.com/event/55405/

# Links

- 2016年、KotlinでAndroid開発する方へ
- http://qiita.com/satorufujiwara/items/871c5b7b66c7691d82a8

- Google I/O 2017 : Introduction to Kotlin (和訳/要約)
- http://qiita.com/satorufujiwara/items/490c1499acec1a921258

- Life is Great and Everything Will Be Ok Kotlin is Here
- https://speakerdeck.com/jakewharton/life-is-great-and-everything-will-be-ok-kotlin-is-here-google-io-2017
- https://www.youtube.com/watch?v=fPzxfeDJDzY

- Kotlin スコープ関数 用途まとめ@Qiita
- http://qiita.com/ngsw_taro/items/d29e3080d9fc8a38691e

- Kotlin入門までの助走読本
- http://goo.gl/5vUT7o

satorufujiwara

May 29, 2017
Tweet

More Decks by satorufujiwara

Other Decks in Programming

Transcript

  1. 4 big themes in Android • Kotlin • Android Studio

    & Libraries • App Quality & Success • Android Instant App
  2. Kotlin in Developer Keynote • First-class Language ʹ • γϯλοΫεϊΠζͷগͳ͍ඒ͍͠ݴޠ

    • Android Studio 3.0 ʹ૊Έࠐ·ΕΔ • Java8 ͷ͞ΒͳΔαϙʔτ(Android O)
  3. buid.gradle buildscript { ext.kotlin_version = '1.1.2-4' dependencies { classpath 'com.android.tools.build:gradle:3.0.0-alpha1'

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } app/build.gradle apply plugin: ‘kotlin-android' dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" }
  4. Why Kotlin? in Developer Keynote • Kotlin͸Javaͱͷ׬શͳ૬ޓӡ༻͕ग़དྷɺ1Ϋϥε͔ΒKotlinԽͰ͖Δ • 100% interoperable

    with Java and Android • ։ൃ͔Β5೥ܦͪɺݴޠ͕੒ख़͠ɺ੡඼൛ͱͯ͠ϦϦʔεՄೳͳঢ়ଶͰ͋ Γɺ࣮ࡍʹ࢖ΘΕ͍ͯΔ • Flipboard,Pinterest ,Square Cash, Expedia • ݴޠ͕ૉ੖Β͍͠ͷʹՃ͑ɺIDEαϙʔτ͕ૉ੖Β͍͠ • Android Studioͷϕʔεͱͳ͍ͬͯΔIntelliJ IDEAͱಉ͡νʔϜ • Kotlin͸طʹApache2ϥΠηϯεͷΦʔϓϯιʔε͕ͩɺ͜Ε͔Β΋Φʔ ϓϯιʔεϓϩδΣΫτͱͯ͠ඇӦརࡒஂ͕։ൃ͍ͯ͘͠
  5. Sessions about Kotlin • Introduction to Kotlin • Life is

    Great and Everything Will Be Ok, Kotlin is Here
  6. Life is Great and Everything Will Be Ok, Kotlin is

    Here • KotlinͰAndroidΛ։ൃ͢Δ্ͰͷTips • by Jake Wharton (Square) @JakeWharton • KotlinΛ͍͔ʹͯ͠ಋೖ͔ͨ͠ʁ • by Christina Lee (Pinterest) @RunChristinaRun • https://speakerdeck.com/jakewharton/life-is-great-and- everything-will-be-ok-kotlin-is-here-google-io-2017 • https://www.youtube.com/watch?v=fPzxfeDJDzY
  7. fun findEmails(users: List<User>, predicate: (String) -> (Boolean)) : List<User> {

    //… } findEmails(users, { value -> value.endsWith(".com") })
  8. fun findEmails(users: List<User>, predicate: (String) -> (Boolean)) : List<User> {

    //… } findEmails(users, { value -> value.endsWith(".com") }) findEmails(users, { it.endsWith(".com") })
  9. fun findEmails(users: List<User>, predicate: (String) -> (Boolean)) : List<User> {

    //… } findEmails(users, { value -> value.endsWith(".com") }) findEmails(users, { it.endsWith(".com") }) findEmails(users) { it.endsWith(".com") }
  10. data class Money(val amount: Int, val currency: String) fun sumUp(money

    : Money?) { if (money != null) { sumOfAmount += money.amount } }
  11. data class Money(val amount: Int, val currency: String) fun sumUp(money

    : Money?) { if (money != null) { sumOfAmount += money.amount } } fun sumUp(money : Money?) { money ?: return sumOfAmount += money.amount }
  12. data class Money(val amount: Int, val currency: String) fun sumUp(money

    : Money?) { if (money != null) { sumOfAmount += money.amount } } fun sumUp(money : Money?) { money ?: return sumOfAmount += money.amount } fun sumUp(money : Money?) { sumOfAmount += money?.amount ?: 0 }
  13. data class Money(val amount: Int, val currency: String) fun sumUp(money

    : Money?) { if (money != null) { sumOfAmount += money.amount } } fun sumUp(money : Money?) { money ?: return sumOfAmount += money.amount } fun sumUp(money : Money?) { sumOfAmount += money?.amount ?: 0 } fun sumUp(money : Money?) { money?.run { sumOfAmount += amount } }
  14. companion object { private const val KEY_USER = “user” fun

    newInstance(user: User): UserFragment { val fragment = UserFragment() val args = Bundle() args.putParcelable(KEY_USER, user) fragment.argument = args return fragment } }
  15. companion object { private const val KEY_USER = “user” fun

    newInstance(user: User): UserFragment { val fragment = UserFragment() val args = Bundle() args.putParcelable(KEY_USER, user) fragment.argument = args return fragment } fun newInstance(user: User): UserFragment { val fragment = UserFragment() fragment.argument = Bundle().apply { putParcelable(KEY_USER, user) } return fragment } }
  16. companion object { private const val KEY_USER = “user” fun

    newInstance(user: User): UserFragment { val fragment = UserFragment() val args = Bundle() args.putParcelable(KEY_USER, user) fragment.argument = args return fragment } fun newInstance(user: User): UserFragment { val fragment = UserFragment() fragment.argument = Bundle().apply { putParcelable(KEY_USER, user) } return fragment } fun newInstance(user: User) = UserFragment().apply { arguments = Bundle().apply { putParcelable(KEY_USER, user) } } }
  17. είʔϓؔ਺ • let / with / run /apply / also

    • Kotlin είʔϓؔ਺ ༻్·ͱΊ@Qiita • http://qiita.com/ngsw_taro/items/ d29e3080d9fc8a38691e
  18. How to start Kotlin • Official Site : kotl.in/ ,

    kotl.in/android • Kotlin is awesome! (kotlin.link/) • Kotlin ελʔτϒοΫ(੺΂͜ຊ) • Kotlin Advent Calendar (2015/2016)
  19. How to start Kotlin • Official Site : kotl.in/ ,

    kotl.in/android • Kotlin is awesome! (kotlin.link/) • Kotlin ελʔτϒοΫ(੺΂͜ຊ) • Kotlin Advent Calendar (2015/2016) • Kotlinೖ໳·Ͱͷॿ૸ಡຊ( goo.gl/5vUT7o )