cont trad cap 25

This commit is contained in:
Victorhck 2021-04-14 19:05:13 +02:00
parent e273a39f74
commit 49b740aa0a

View file

@ -281,32 +281,32 @@ echo exists("una_docena") && una_docena == 12
## For ## For
The `for` loop is commonly used with the list data type. El bucle `for` es comunmente utilizado con el tipo de datos listas.
``` ```
let breakfasts = ["pancakes", "waffles", "eggs"] let desayunos = ["tortitas", "gofres", "huevos"]
for breakfast in breakfasts for comida in desayunos
echo breakfast echo comida
endfor endfor
``` ```
It works with nested list: También funciona con listas anidadas:
``` ```
let meals = [["breakfast", "pancakes"], ["lunch", "fish"], ["dinner", "pasta"]] let meals = [["desayuno", "tortitas"], ["almuerzo", "pescado"], ["cena", "pasta"]]
for [meal_type, food] in meals for [tipo_comida, comida] in meals
echo "I am having " . food . " for " . meal_type echo "Estoy tomando " . comida . " para " . tipo_comida
endfor endfor
``` ```
You can technically use the `for` loop with a dictionary using the `keys()` method. Técnicamente puedes utilizar el bucle `for` con un diccionario utilizando el método `keys()`.
``` ```
let beverages = #{breakfast: "milk", lunch: "orange juice", dinner: "water"} let bebidas = #{desayuno: "leche", almuerzo: "zumo de naranja", cena: "agua"}
for beverage_type in keys(beverages) for tipo_de_bebida in keys(bebidas)
echo "I am drinking " . beverages[beverage_type] . " for " . beverage_type echo "Estoy bebiendo " . bebidas[tipo_de_bebida] . " para " . tipo_de_bebida
endfor endfor
``` ```