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

Kotlin, The Force Awakens

Kotlin, The Force Awakens

Introduction to Kotlin language, chapter I

Yury Camacho

June 03, 2017
Tweet

More Decks by Yury Camacho

Other Decks in Technology

Transcript

  1. What is Kotlin? • JVM • Seems like Java •

    Object Oriented • Functional • Less code than Java • No need Classes • Null safety
  2. Variables y mutability val name: String = "Kylo Ren" var

    side = "Force" side = "Dark Side" name = "Kylo" //no compile!!!
  3. “If” is so cool! var sable = true; println( if

    (sable) { "Activate" }else { "Deactivated" })
  4. Null Safety // error no compile var clone: String =

    null //can not be a value of a non-null type String // could be null var clone2: String? = null clone2 = "clone" // I’m sure, clone2 is not null println( clone2!! )
  5. Functions • No need to be part of a class

    • “fun” keyword for create a function • Default parameters • Named Parameters • Extension functions
  6. Herencia open data class Character(var name: String, var sable:Boolean =

    false ){ } class SecCharacter(name: String) : Character(name){ }
  7. Bye bye POJO data class Character(var nombre: String, var sable:Boolean

    = false ){} //function by default kylo.toString() kylo.hashCode() kylo.equals() //setters and getters by default kylo.name kylo.sable