Mention what are the collection types available in Swift?
Answer / 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 |
How can you prioritize the usability of the demand process?
What are the collection types available in swift?
In swift, what type of object are basic data types?
Explain core data.
What is the usage of switch statement in swift language?
How can you write a comment in swift?
Explain the usage of class and benefits of inheritance.
What are the collection types that are available in swift?
Can any be nil swift?
How to make a method or variable generics in swift?
Explain what Lazy stored properties is and when it is useful?
Is swift an oop?