Language features of Swift

Source: Internet
Author: User

Simplicity and security are the basic ideas behind Swift's design.

  • Less input: No semicolon required? Represents optional, the parentheses require less, the initialization of arrays and dictionaries, and switch has no break

  • Borrowed a lot of ideas of functional programming

  • var and let represent variable and solid

  • Set, GET, Willset, Didset

  • Enhanced enumeration types

  • Type-safe language and type inference

  • function is a one-class citizen, closures

  • Type alias Typealias, from the idea of C/

  • An enhanced tuple (tuple) that can mix any number of any type. is useful for function return values.

  • Optional: Indicates that a value exists and is x, or that the value does not exist. can handle NULL, nil condition.? Represents the type that has been optional wrapped! Indicates that a value of type optional exists and there will be a run-time exception if it does not exist.

  • Nil is not the same in objective-c and Swift. Objective-c nil means that the pointer points to an object that does not exist. Swift's nil represents a state in which the variable has not been assigned a value.

  • operator Enhancement: = Do not return a value, avoid the error with = = for the conditional expression. By default, overflow is not allowed. Range Operator: ... (fully closed) and. (semi-closed).

  • Enhanced switch, supports range matching, supports tuple matching, supports match-time-value bindings, and WHERE clauses


Language features of Swift

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.