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

Kotlin por onde começar?

Kotlin por onde começar?

Como começar no Kotlin para Android

José Caique Oliveira

July 08, 2017

Transcript

17 slides
  1. val e var val nome : String = “Caique” nome

    = “José” (erro) var nome1 : String = “Caique” nome1 = “Oliveira” https://goo.gl/Uef9D2
  2. Criando um objeto class Client { } val client =

    Client() https://goo.gl/1bqnX S
  3. Construtor no Kotlin Class Client constructor(var name: String, var city

    : String) { fun printName(){ print(name) } } https://goo.gl/KFcmnV
  4. Data class - Classes para a representação de dados data

    class User(val name: String,val age: Int) https://goo.gl/DRxvPy
  5. Criando funções com o Kotlin fun double(value: Int) : Int

    { return value * 2 } fun sum(a: Int,b : Int = 0){ return a + b } sum(1) sum(2,3) https://goo.gl/TZdf2Y
  6. for for ( i in 0 .. 2 ) {

    } for(client : Client in clients) { } https://goo.gl/fYZNNU
  7. run - chama um bloco de código e retorna um

    resultado dialog?.run{ isVisible } https://goo.gl/ChNq4d
  8. Extensions - Possível adicionar novos comportamentos a uma classe fun

    View.visible() { visibility = View.VISIBLE } antes imageView.visibility = View.VISIBLE depois imageView.visible() https://goo.gl/N4isRx
  9. Kotlin- Extensions: Adeus findViewById adicionar ao cabeçalho do gradle: apply

    plugin: ‘kotlin-android-extensions’ antes val button = findViewById(R.id.button) as Button button.setOnClickListener{ } depois //val button = findViewById(R.id.button) as Button button.setOnClickListener{ } https://goo.gl/kx1GXJ

More Decks by José Caique Oliveira

Other Decks in Programming