The note on the Swift Programming Language-page 27th

Source: Internet
Author: User

· page No.

1 type Safelanguage

The main content of this page is that the Swift language is a safe programming language for " type checking " . This means that the lvalue and rvalue types of an assignment statement are consistent, and the Lvalue declaration is a string variable, so the right value of the equal sign is the one that is caused by the double-argument. Instead of shaping or floating-point data.

The compiler checks the left and right values of an assignment statement when compiling code. Assume that the type does not match. Compiler error, that is, to do data security checks to ensure consistency of data.

2 Type Inferencelanguage

Swift the consistency of data types is checked at compile time, but does not mean that variables or constants must be typed when defining constants and variables. Can not describe the type, because Swift has a mechanism called type inference language.

Swift the compiler of a language automatically determines whether the constant or variable should belong to that data type, based on the initialization assignment statement of the constant or variable.

eg1:let S1 = " www.chinagame.me "

This statement , Swift , is based on the Lvalue "www.chinagame.me" of an assignment statement and determines the type of the S1 constant is string .

this Swift It is not necessary for a program developer to define as follows S1 constant.

Let s1:string = " www.chinagame.me "

under the type inference mechanism

Let s1 = " www.chinagame.me "

and let s1:string = "www.chinagame.me" declaration S1 is a constant equivalent.

Key Words: type Check , type safe Languagge , type inference



The note on the Swift Programming Language-page 27th

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.