Skip to content

Instantly share code, notes, and snippets.

@GabriellCosta
Created June 16, 2020 02:17
Show Gist options
  • Save GabriellCosta/bbd3527ae18e40bcc0f542811c33a455 to your computer and use it in GitHub Desktop.
Save GabriellCosta/bbd3527ae18e40bcc0f542811c33a455 to your computer and use it in GitHub Desktop.
Criando obejtos e utilizando eles em um Scratch
//Criamos uma classe
data class Sample(
val number: Int
) {
//Aqui temos um pequeno override so para exemplificar
override fun toString(): String {
return "Meu numero é $number"
}
}
//então podemos criar uma lista de itens do tipo
val list = listOf(Sample(3), Sample(4), Sample(99))
//E ver facilmente o seu resultado
println(list.maxBy { it.number })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment