Skip to content

Instantly share code, notes, and snippets.

@jdnichollsc
Last active March 22, 2019 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdnichollsc/962eee58ef626defcd2299d09d536ea8 to your computer and use it in GitHub Desktop.
Save jdnichollsc/962eee58ef626defcd2299d09d536ea8 to your computer and use it in GitHub Desktop.
Android - Kotlin
interface Demo {
val context:Context
fun alert(mensaje:String)
{
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}
}
object SimpleSingleton {
    val answer = 42;
    fun greet(name: String) = "Hello, $name!"
}
//val is like a constant
data class Item (val name: String, var year: Int?) {
}
val item = Item(name = "Moto", year = 2014)
val item2 = item.copy(year = null)
// Funciones extendidas
fun Activity.alert(mensaje:String)
{
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment