Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Mention what are the collection types available in Swift?

Answer Posted / iosraj

In Swift, collection types come in two varieties Array and Dictionary

Array: You can create an Array of a single type or an array with multiple types. Swift usually prefers the former one

Example for single type array is,

Var cardName : [String] = [ “Robert” , “Lisa” , “Kevin”]

// Swift can infer [String] so we can also write it as:

Var cardNames = [ “Robert”, “Lisa”, “Kevin”] // inferred as [String]

To add an array you need to use the subscript println(CardNames[0])

Dictionary: It is similar to a Hash table as in other programming language. A dictionary enables you to store key-value pairs and access the value by providing the key

var cards = [ “Robert”: 22, “Lisa” : 24, and “Kevin”: 26]

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is swift nsarray?

723


How to write a multiple line comment in swift?

827


What is retain in swift?

776


What are the two main integer types in swift?

799


What is nil-coalescing operator?

742


What is the floating point numbers and what are the types of floating number in swift?

835


What is differences in swift 1.x, 2.x, 3.x, 4.x?

746


What is core data swift?

722


Is swift like python?

764


What is the significance of “?” In swift?

821


What are the control transfer statements that are used in ios swift?

945


What is bridging header in swift?

732


What is protocol in swift?

793


What is an attribute in swift?

826


Do try catch swift?

702