Expressions for Swift

Source: Internet
Author: User

In swift, expressions have many forms


1. Do not specify a data type


var a1=10


var a2=20


var a=a1>a2? " A1 ":" A2 "


In the above expression, the variable or constant is assigned directly, and no data type is specified because Swift can automatically determine the data type



2. Specify the data type


var a1:int=10

var a2:int=20


var a=a1>a2? " A1 ":" A2 "


In the above expression, specify the int data type for variables and constants, which makes the program readable;


3. Using layering


var A1:int=10;var a2:int=20

var a=a1>a2? " A1 ":" A2 "


In the swift language, a statement can be terminated without a semicolon or a semicolon, but there is a case where a semicolon is required, that is, when multiple statements are written on the same line, a semicolon is used to differentiate the statement, for example:








This article is from the "Ordinary Road" blog, please be sure to keep this source http://linjohn.blog.51cto.com/1026193/1619004

Expressions for Swift

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.