Created
December 9, 2016 05:22
-
-
Save jamesrochabrun/a87f5f2d792ec749d77f126e6f60bea1 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
//: Playground - noun: a place where people can play | |
import UIKit | |
var str = "Hello, playground" | |
var animals: Array = ["duck", "dog", "rabbit"] | |
for animal in animals { | |
print(animal) | |
} | |
//this changed from for ( int i = 1, 1 < 10 , i++) | |
for var i in (1...10).reversed() { | |
print("la variable reversed i vale \(i)") | |
} | |
for var x in (1...10) { | |
print("la variable x vale \(x)") | |
} | |
print("===================================================") | |
//WHILE LOOP | |
var z = 0 | |
var found = false | |
while !found { | |
z = z + 1 | |
if z % 5 == 0 && z % 7 == 0 && z > 7 { | |
found = true | |
print("\(z) is multiple of 5") | |
} | |
} | |
print("===================================================") | |
//for loops with arrays | |
//posicion y valor :) | |
for (index, animal) in animals.enumerated() { | |
print("el animal en el index \(index) es \(animal)") | |
} | |
//for loops with dictionaries | |
var extras :Dictionary = ["hawaiana" : "piña", "china" : "salame", "peruana": "chorizo"] | |
for (key, value) in extras { | |
print("el valor de \(key) es \(value)") | |
} | |
for (key) in extras.keys { | |
print("el valor es \(extras[key]!)") | |
print(key) | |
} | |
for (value) in extras.values { | |
print(value) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment