A place to breathe

Monday, July 7, 2014

Swift Syntax overview - Array and Dictionary

We declare arrays in Swift as follows:

var myJobs = String()[]    //empty array
var myBooks = ["bus ride", "computer", "cars", "road to success"]    //initialize Array with values

Accessing it using array:

var bestSeller = myBooks[1]

Dictionary:

var bestBoss = Dictionary < String,Float > ()     //empty dictionary
var bestEmployee = [
       "Kyle" : "computer engineer",
       "Jason" : "web developer", 
       "Azeez" : "designer",


No comments:

About Me

I'm currently a software engineer. My specific interest is games and networking. I'm running software company called Nusantara Software.