Last active
March 22, 2019 23:58
-
-
Save jdnichollsc/962eee58ef626defcd2299d09d536ea8 to your computer and use it in GitHub Desktop.
Android - Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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