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
Can you explain regular expression and responder chain?
How can you define a base class in swift?
What collection types are available in swift?
Is equal to string swift?
What is interface in swift?
How do I add a bridging header in swift?
How many types of closures are there in swift?
What is $0 and $1 in swift?
What is forced unwrapping?
What are the various ways to unwrap an optional in swift?
What is dependency injection in swift?
What are adapter and memento patterns?
Explain deinitializer in swift programming language?
Explain functions?
How proficient are you in objective-c and swift? Can you briefly describe their differences?