Initialization of array and dictionary creation in Swift

Source: Internet
Author: User

First look at Swift's method of initializing array, and the following types take int as an example

var a1 = [1, 2, 3]

var a2:int[] = [1, 2, 3]

var a3:int[] = int[] ([1, 2, 3])

var a4:int[] = array<int> ([1,2,3])

var a5:array<int> = [1,2,3,]

var a6 = array<int> ([1,2,3])

var a7:array<int> = array<int> ([1,2,3])

The next step is dictionary, because its internal Init method is implemented with a much less initialization method, with string, string as an example

var D1 = ["1": "2"]

var d2:dictionary<string, string> = ["1": "2"]

var d3:dictionary<string, string> = dictionary<string, string> ()

var d4 = dictionary<string, string> ()


The methods listed above are also studied and tested by the Swift programming language, if there is any other way, please leave a message for your friends.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.