Skip to content

Instantly share code, notes, and snippets.

@leonus96
Created October 24, 2023 02:29
Show Gist options
  • Save leonus96/285034ea06978727b703d670ce5c478f to your computer and use it in GitHub Desktop.
Save leonus96/285034ea06978727b703d670ce5c478f to your computer and use it in GitHub Desktop.
for
void main() {
/// Bucle FOR
/// El bucle for es útil cuando se
/// conoce de antemano el número de iteraciones
/// que se deben realizar.
/// Sintaxis:
/// for (inicialización; condición; actualización) {
/// -- Código a ejecutar en cada iteración --
/// }
// Ej1 :
/*for (int i = 0; i < 10; i++) {
print('${i + 1} Hola mundo');
}*/
// Ej2 :
/*final List<String> alumnos = [
'Alexander',
'Axel',
'Carlos1',
'Carlos2',
'Cesar',
'Eddie',
'Katerin',
];
for(int i = 0; i < alumnos.length; i++) {
print('${i+1} ${alumnos[i]}');
}*/
// Ej 2:
/* final Map<String, int> edades = {
'Joseph': 27,
'Alexander': 26,
'Carlos': 15,
};
final List<String> claves = edades.keys.toList();
for(int i = 0; i < claves.length; i++) {
print('La edad de ${claves[i]} es ${edades[claves[i]]}');
}*/
// Ej 3:
/*final List<int> enteros = [
2,
3,
6,
12,
4,
7,
10,
232,
];
for (int i = 0; i < enteros.length; i++) {
print('$i ==> ${enteros[i]}');
}*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment