Skip to content

Instantly share code, notes, and snippets.

@davidbreyer
Created June 11, 2014 15:58
Show Gist options
  • Save davidbreyer/a421c98c4d4e9a6e4208 to your computer and use it in GitHub Desktop.
Save davidbreyer/a421c98c4d4e9a6e4208 to your computer and use it in GitHub Desktop.
Create and Update Generic List in Apple Swift
//
// 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