// Bucle While
var contadorWhile = 1
while contadorWhile <= 10 {
print("While: \(contadorWhile)")
contadorWhile += 1
}
// Bucle Do-While
var contadorDoWhile = 1
repeat {
print("Do-While: \(contadorDoWhile)")
contadorDoWhile += 1
} while contadorDoWhile <= 10
// Bucle For
for i in 1...10 {
print("For: \(i)")
}
// Bucle ForEach
(1...10).forEach { numero in
print("ForEach: \(numero)")
}
// Bucle ForEach Abreviado
(1...10).forEach {
print("ForEach Abreviado: \($0)")
}
Publicado el día 28 de diciembre de 2023CATEGORÍAS
Swift, Xcode