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
val productos = arrayOf("Camiseta", "Pantalón", "Zapátos") |
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
val unaCadenaDeTexto = "abcd 123" |
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
val unCaracter: Char = 'a' |
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
val verdadero: Boolean = true | |
val falso: Boolean = false | |
val sinValor: Boolean? = null |
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
val pi = 3.14 // Double | |
val uno: Double = 1 // Error: El tipo de dato no es el mismo | |
val unoDouble = 1.0 // Double |
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
val uno = 1 // Int | |
val tresMilMillones = 3000000000 // Long | |
val unoQuePodriaSerMasLargo = 1L // Long | |
val unByte: Byte = 1 |
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
var cuentaDeBanco = 1000 | |
val sueldo = 10_000 | |
cuentaDeBanco += sueldo | |
println(cuentaDeBanco) |
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
val sueldo | |
var cuentaDeBanco |
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
fun /* <- 1. Palabra clave que indica que esto es una función */ | |
sumOf /* <- 2. Nombre de la función */ | |
( /** <- | |
* 3. Parentesis que indican en donde escribir los argumentos | |
* necesarios para escribir la función | |
*/ | |
a: Int /* 4. El primer argumento de la función */, | |
b: Int /* El segundo argumento escrito después de la coma */ | |
/** | |
* Si queremos otro argumento, sólo tenemos que agregar una coma antes. |
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
/** | |
* 1 Función principal. Esta es la función que se ejecuta cuando le damos | |
* click al botón de play. | |
*/ | |
fun main() { | |
// 2 Dos valores para ser utilizados por nuestra función sumOf | |
val a = 2 | |
val b = 2 | |
// 4 El resultado de la suma se guarda en aPlusB | |
val aPlusB = sumOf(a, b) |
NewerOlder