Skip to content

Instantly share code, notes, and snippets.

@dylankbuckley
Created December 12, 2016 22:14
Show Gist options
  • Save dylankbuckley/069ba45845e6ba20065f2ca2d3f27459 to your computer and use it in GitHub Desktop.
Save dylankbuckley/069ba45845e6ba20065f2ca2d3f27459 to your computer and use it in GitHub Desktop.
Learn Swift 3.0 & Xcode 8 (Part 2 - Swift Basics)
// For Loop
for index in 1...5 {
print("\(index) times 2 is \(index * 2)")
}
// Array
let myAnimals = ["Fluffy", "Stevey", "Rabbit", "Doggy"]
let randomNumbers = [1, 2, 3, 4, 5]
for animal in myAnimals {
print("This animal is called \(animal)")
}
// Password Checker
// See if a users password is correct - if it is tell them it is, if not tell them to try again.
let myPassword = "Rabbit123"
let passwords = ["SillyBill123", "HelloWorld", "AdamsApple728", "Rabbit123", "SteveyWonder"]
for password in passwords {
if myPassword == password {
print("Your Password is Correct")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment