Skip to content

Instantly share code, notes, and snippets.

@sag333ar
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sag333ar/a4a06049fd7eded9a115 to your computer and use it in GitHub Desktop.
Save sag333ar/a4a06049fd7eded9a115 to your computer and use it in GitHub Desktop.
Exercise3 : Declaring / modifying / displaying an array. Declaring / modifying / displaying key-valued array. Creating empty array & key-valued empty array.
//: Playground - noun: a place where people can play
// The Swift Programming Language
// Basics of Array & key-valued array
import UIKit
var str = "Hello, playground"
// creating / declaring an array
var shoppingList = ["catfish", "water", "tulips", "blue paint"]
// modifying the array element
shoppingList[1] = "bottole of water"
// displaying the value of an array
println(shoppingList)
// declaring dictionary(key valued array)
var occupations = [
"sagar" : "ios s/w dev",
"ankit" : "ios s/w dev",
"samurai" : "cartoon character"
]
// displaying dictionary(key valued array)
println(occupations)
// adding value to dictionary(key valued array)
occupations["amit"] = "system admin"
// displaying dictionary(key valued array)
println(occupations)
// declaring empty array
let myEmptyArray = []
// declaring an empty array with string data type
let myEmptyStringArray = [String]()
// declaring an empty dictionary(key valued array)
let myKeyValuedEmptyArray = [:]
// declaring an empty dictionary(key valued array) with specific data type
let myEmptyKeyValuedArrayWithType = [String:Float]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment