Skip to content

Instantly share code, notes, and snippets.

@leonus96
Created October 24, 2023 02:12
Show Gist options
  • Save leonus96/bc55d44936e7c78db97764dbd657e23a to your computer and use it in GitHub Desktop.
Save leonus96/bc55d44936e7c78db97764dbd657e23a to your computer and use it in GitHub Desktop.
while
void main() {
/// Bucle while:
/// El bucle while se utiliza para repetir
/// una serie de intrucciones mientras una
/// condición sea verdadera.
/// Sintaxis:
/// while(condicíon) {
/// -- Código que queremos ejecutar repetidamente.
/// }
/// int contador = 0;
/// while(contador < 5) {
/// contador = contador + 1;
/// print('Contador: $contador');
///}
///print('Fin del programa');
/// A, B, C, D, E length = 5
/// 0, 1, 2, 3, 4
///i =0 1 2 3 4
/*final List<String> alumnos = [
'Alexander',
'Axel',
'Carlos1',
'Carlos2',
'Cesar',
'Eddie',
'Keterin',
];
int i = 0; //1
while (i < alumnos.length) {
print('${i + 1}. ${alumnos[i]}');
i = i + 1;
}*/
/*final Map<String, int> edades = {
'Joseph': 27,
'Alexander': 26,
'Carlos': 15,
};*/
/// final List<String> claves = edades.keys.toList();
/// ['Joseph', 'Alexander', 'Carlos']
/// Forma 1:
/*int i = 0;
while(i < claves.length) {
print('La edad de ${claves[i]} es ${edades[claves[i]]}');
i++;
}*/
/// Forma 2:
/*int i = 0;
while(i < claves.length) {
final clave = claves[i];
print('La edad de ${clave} es ${edades[clave]}');
i++;
}*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment