Created
June 11, 2014 15:58
-
-
Save davidbreyer/a421c98c4d4e9a6e4208 to your computer and use it in GitHub Desktop.
Create and Update Generic List in Apple Swift
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
// | |
// main.swift | |
// ConsoleApp1 | |
import Foundation | |
var cityList = Array<String>() | |
cityList.append("Vienna") | |
cityList.append("Munich") | |
cityList.append("Berlin") | |
cityList.append("Prague") | |
println("Number of elements in city list:") | |
println(cityList.count) | |
//Create a filtered list of elements that match the specified criteria | |
let filtered = cityList.filter({$0 == "Prague"}) | |
println("Number of elements in filtered list:") | |
println(filtered.count) | |
println("Enumerate city list:") | |
for item in cityList | |
{ | |
println(item) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment