Swift Learning Notes (24)--constant array and constant dictionary __swift

Source: Internet
Author: User

As with other data types in swift, arrays and dictionaries can be defined separately as Var,let, which is variables and constants. Arrays and dictionaries that are defined as let constants are immutable. Here's a quick look:

Import Uikit let

courses_dict = [1: "Advanced Mathematics", 2: "College English", 3: "Program Design"]  //constant let

Course_array = ["Advanced mathematics", "College English", "Program Design") "]   //Constant

Courses_dict.removevalueforkey (3)    //error, cannot delete
courses_dict.updatevalue (" level 46 ", Forkey:2)  //error, cannot modify
courses_dict[4] = "level 46"    //error, cannot insert


course_array.removeatindex (0)  //error, cannot delete
COURSE_ARRAY[1] = "level 46"   //error, cannot modify
course_array[3] = "linear algebra"  //error, cannot insert



GitHub home: https://github.com/chenyufeng1991. You are welcome to visit.

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.