SWIFTL Outstanding Features

Source: Internet
Author: User

The swift language absorbs many excellent languages such as Java. After C++,python. Provides a number of excellent features to developers.

Here's a list of some of the great features of Swift:

1. function uses classic parentheses and point call syntax


2. Function Tag Characteristics

The function tag in objective-c is also part of the function parameter, which avoids the meaning of each parameter in case of too many parameters. Objective-c's excellent features were inherited by Swift. Swift also supports tags.


3. Strict type checking

Swift discards consideration of the loose type checking method in Objective-c. In turn, strict type checking and conversion operations are used. Since all swift types are structs or classes, there is no basic type. Therefore, the conversion based on the value copy is a copy operation. A reference-based approach is to use As,as? Operation to proceed.


4. True object-oriented language

Swift is a fully object-oriented language. itself has constructors and destructors, and constructors are functions that begin with init. Destructors are functions that begin with Deinit.

Attention. The constructor calls itself at the time of the creation of the object, without the need for the program ape to invoke the INIT function on its own initiative, which is invoked by itself at the end of the object's life cycle.


5. Namespaces

For Swift, namespaces are also one of the big features.

In the probably iOS development. Especially for some enumeration types. You can simply access the different parts of the content, the same prefix can be omitted.


6. Generic Processing

Generics are an important feature of Swift and one of Swift's supposedly secure, type-critical embodiment. For objects in Objective-c can hold whatever object, but for Swift can only hold the object of the specified object or the specified protocol.

This limits the type mismatch characteristics from the level of the compiled code. Either the system comes with an array. or a dictionary or an object of your own definition. Can be handled using generics.


7. Closed Package closure

Closures are a feature of modern languages, which simply means that child functions can access objects within the parent function.

Swift's closures and Objective-c's blocks have similarities. Swift closures also comply with ARC memory management.

Closures play a significant role in communication between objects, callback functions, and reverse-passing values.

Network download is a common closure processing function. Both common closures and trailing closure functions are used primarily for callback callback.

SWIFTL Outstanding Features

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.