-
-
Save parzibyte/1289fbbc3a4a50283bda35384289c0e9 to your computer and use it in GitHub Desktop.
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 main() { | |
// by parzibyte | |
// Definir un arreglo con arrayOf | |
val nombres = arrayOf("Luis", "María José", "Fernando") | |
println(nombres[1]) // María José | |
for (nombre in nombres){ | |
println(nombre) | |
} | |
for (indice in nombres.indices){ | |
println("En el índice ${indice} tenemos a ${nombres[indice]}") | |
} | |
// Declararlo con su longitud y una función de init | |
val arregloDeEnteros = Array(5, { indice -> indice + 1}) | |
// Se puede modificar como cualquier arreglo | |
arregloDeEnteros[2] = 500 | |
for (numero in arregloDeEnteros){ | |
println(numero) | |
} | |
// Acceder a longitud | |
val longitud = arregloDeEnteros.size | |
println("La longitud del arreglo es $longitud") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment