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

Kotlin sintax overview

Kotlin sintax overview

This talk is result of my presentation on AndroidStudyJams Maceió

Felipe Oliveira

April 30, 2016
Tweet

More Decks by Felipe Oliveira

Other Decks in Programming

Transcript

  1. Sintaxe overview: classes class Person {} open class Person {}

    data class Person(val name: String, val age: Int)
  2. Sintaxe overview: Null safety val person: Person? = Person("Felipe",24) fun

    main(args: Array<String>) { print(person?.name) }
  3. Sintaxe overview: Default arguments fun query(table: String, columns: Array<String>, orderBy:

    String? = null, limit: Int? = null){ ... } query("PEOPLE", arrayOf("ID","NAME")) query("PEOPLE", arrayOf("ID","NAME") , limit = 10)
  4. Instalando plugin no Android Studio apply plugin: 'kotlin-android' android {

    ... sourceSets { main.java.srcDirs += 'src/main/kotlin' } ... } dependencies { ... compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" ... } buildscript { ext.kotlin_version = '1.0.1-2' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }
  5. Referências Jake Wharton https://plus.google.com/+JakeWharton/posts/WSCoqkJ5MBj Kotlin lang docs reference https://kotlinlang.org/docs/reference Antonio

    Leiva Blog http://antonioleiva.com/kotlin/ Comece agora a brincar com kotlin http://try.kotlinlang.org/