Skip to content

Instantly share code, notes, and snippets.

View halilozel1903's full-sized avatar
πŸ¦…
The rest of the world was black and white πŸ–€ 🀍

Halil Γ–zel halilozel1903

πŸ¦…
The rest of the world was black and white πŸ–€ 🀍
View GitHub Profile
let names = ["Halil", "Δ°brahim", "Yusuf", "Emre"]
let count = names.count
for i in 0..<count {
print("Person \(i + 1) is called \(names[i])")
}
// Person 1 is called Halil
// Person 2 is called Δ°brahim
// Person 3 is called Yusuf
// Person 4 is called Emre
val names = arrayOf("Halil", "Δ°brahim", "Yusuf", "Emre")
val count = names.count()
for (i in 0..count - 1) {
println("Person ${i + 1} is called ${names[i]}")
}
// Person 1 is called Halil
// Person 2 is called Δ°brahim
// Person 3 is called Yusuf
// Person 4 is called Emre
for index in 1..5 {
print("\(index) Halil Γ–zel")
}
for (index in 1..5) {
println("$index Halil Γ–zel")
}
var shoppingList = ["milk", "water",
"egg", "rice"]
shoppingList[1] = "bread"
val shoppingList = arrayOf("milk", "water",
"egg", "rice")
shoppingList[1] = "bread"
var occupations = [
"Malcolm": "Captain",
"Kaylee": "Mechanic",
]
occupations["Kaylee"] = "Public Relations"
val occupations = mutableMapOf(
"Malcolm" to "Captain",
"Kaylee" to "Mechanic"
)
occupations["Kaylee"] = "Public Relations"
let emptyArray = [String]()
let emptyDictionary = [String: Float]()
val emptyArray = arrayOf<String>()
val emptyMap = mapOf<String, Float>()