Last active
August 29, 2015 14:27
-
-
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.
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
//: 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